Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Answers
AngularJS: service and factory is singleton ?
tri_inn
7y
771
1
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
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
AngularJS: factory and share data between controllers
AngularJS: infinite scroll with ng-repeater