Last active
August 29, 2015 14:27
-
-
Save F1LT3R/be1d78916bc11b224550 to your computer and use it in GitHub Desktop.
something.js
This file contains 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
// In the app | |
app.factory('MyService', [function () { | |
return { | |
mydata: "Hello world!", | |
myfunc: function(a, b) { | |
return a+b; | |
} | |
} | |
}]); | |
// In the Protractor test | |
browser.executeScript(function() { | |
return angular.element(document).injector().get('MyService'); | |
}).then(function(MyService){ | |
console.log(MyService.mydata); | |
// logs: "Hello World!" | |
console.log(MyService.myfunc); | |
// logs: "{}" | |
MyService.myfunc(2, 2); | |
// "TypeError: object is not a function" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment