Created
September 16, 2015 15:59
-
-
Save qetr1ck-op/8ef78320b0af84631e00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.factory('greeterFactory', function(a) { | |
function Greeter(a) { | |
this.greet = function() { | |
return 'Hello ' + a; | |
} | |
} | |
return new Greeter(a); | |
}); | |
//or with service | |
module.service('greeterService', function(a) { | |
this.greet = function() { | |
return 'Hello ' + a; | |
} | |
}); | |
function Controller(greeterFactory, greeterService) { | |
expect(greeter instanceof Greeter).toBe(true); | |
expect(greeter.greet()).toEqual('Hello 123'); | |
const greeter2 = new greeter2; | |
expect(greeter2 instanceof greeterFactory).toBe(true); | |
expect(greeter2.greet()).toEqual('Hello 123'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment