i search a lot for example which i can run and see that angular service and 
factory is singleton in nature because i heard many time that these are 
singleton in nature when i read many write up on difference between service 
and factory but none one show this that these are singleton with example 
and code.

i am new in angular. so very curious to know how could i write a program 
which tell me that service and factory is singleton. if possible please 
provide a example. 


*sample service and factory*


var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
    this.sayHello = function() {
        return "Hello, World!";
    };});
//factory style, more involved but more sophisticated
myApp.factory('helloWorldFromFactory', function() {
    return {
        sayHello: function() {
            return "Hello, World!";
        }
    };});

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to