Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
AngularJS: service and factory is singleton ?
tri_inn
Jun 12 2017 10:36 AM
753
Reply
How could i prove with a sample code that angular service and factory is singleton
angular.module(
'myApp'
).service(
'helloService'
,function($timeout){
this
.sayHello=function(name){
$timeout(function(){
alert(
'Hello '
+name);
},2000);
}
});
angular.module(
'myApp'
).controller(
'TestController'
,
function(helloService){
helloService.sayHello(
'AngularJS'
);
// Alerts Hello AngularJS
});
so please come with a example code which tell me when i will run that angular service and factory is singleton. thanks
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
AngularJS: factory and share data between controllers
AngularJS: infinite scroll with ng-repeater