angular.service vs angular.factory

angular.service(‘myService’, myServiceFunction); angular.factory(‘myFactory’, myFactoryFunction); I had trouble wrapping my head around this concept until I put it to myself this way: Service: the function that you write will be new-ed: myInjectedService <—- new myServiceFunction() Factory: the function (constructor) that you write will be invoked: myInjectedFactory <— myFactoryFunction() What you do with that is up to … Read more

AngularJS Multiple ng-app within a page

So basically as mentioned by Cherniv we need to bootstrap the modules to have multiple ng-app within the same page. Many thanks for all the inputs. var shoppingCartModule = angular.module(“shoppingCart”, []) shoppingCartModule.controller(“ShoppingCartController”, function($scope) { $scope.items = [{ product_name: “Product 1”, price: 50 }, { product_name: “Product 2”, price: 20 }, { product_name: “Product 3”, price: … Read more

Removing the fragment identifier from AngularJS urls (# symbol)

Yes, you should configure $locationProvider and set html5Mode to true: angular.module(‘phonecat’, []). config([‘$routeProvider’, ‘$locationProvider’, function($routeProvider, $locationProvider) { $routeProvider. when(‘/phones’, {templateUrl: ‘partials/phone-list.html’, controller: PhoneListCtrl}). when(‘/phones/:phoneId’, {templateUrl: ‘partials/phone-detail.html’, controller: PhoneDetailCtrl}). otherwise({redirectTo: ‘/phones’}); $locationProvider.html5Mode(true); }]);

What is the difference between ‘@’ and ‘=’ in directive scope in AngularJS?

Why do I have to use “{{title}}” with ‘@‘ and “title” with ‘=‘? @ binds a local/directive scope property to the evaluated value of the DOM attribute. If you use title=title1 or title=”title1″, the value of DOM attribute “title” is simply the string title1. If you use title=”{{title}}”, the value of the DOM attribute “title” … Read more