Skip to main content

Posts

Showing posts with the label Are angular controllers singletons

Are AngularJs controllers singletons ?

AngularJs code-sample var app = angular.module( 'singletonApp' , []); app.controller( 'singletonTest' , function ($scope, singletonService) {     $scope.name = singletonService.getValue(); }); app.service( 'singletonService' , function () {     var field = {         value: 'hello Anil'     };     var getValue = function () {         return val;     }     return {         getValue: getValue     }; }); HTML code < div ng-app =" singletonApp ">     < div ng-controller =" singletonTest ">              < input type ="text" ng-model =" name.value " />     </ div > </ div > For more, go to link http://bl...