Reputation: 15770
Is there any difference/preference between:
inject(function($injector) {
rootScope = $injector.get('$rootScope');
});
And
inject(function($rootScope){
rootScope = $rootScope;
});
Are the eqal as far as getting a resource injected into a test in Jasmine?
Upvotes: 1
Views: 515
Reputation: 40337
From the documentation on the inject function:
The inject function wraps a function into an injectable function. The inject() creates new instance of $injector per test, which is then used for resolving references.
So, to answer your question, no, there really isn't a difference in the two ways, other than (in my opinion) it's a lot easier to just use the inject function to get dependencies instead of going through the $injector
Upvotes: 1