mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
fix:scope - reintroduce support for eager services
8cad231 broke $eager services
Problem is that the injector.eager function is not invoked when a new scope
is created. Added a test to make sure service is eagerly instantiated.
Closes #403
This commit is contained in:
parent
65b6e48742
commit
bad62d87a1
2 changed files with 8 additions and 1 deletions
|
|
@ -525,7 +525,7 @@ function createScope(parent, providers, instanceCache) {
|
|||
* @param {string} serviceId String ID of the service to return.
|
||||
* @returns {*} Value, object or function returned by the service factory function if any.
|
||||
*/
|
||||
instance.$service = createInjector(instance, providers, instanceCache);
|
||||
(instance.$service = createInjector(instance, providers, instanceCache)).eager();
|
||||
}
|
||||
|
||||
$log = instance.$service('$log');
|
||||
|
|
|
|||
|
|
@ -516,6 +516,13 @@ describe('angular', function(){
|
|||
angular.service('svc2', function(svc1) { return 'svc2-' + svc1; });
|
||||
expect(angular.scope().$service('svc2')).toEqual('svc2-svc1');
|
||||
});
|
||||
|
||||
it('should eagerly instantiate a service if $eager is true', function() {
|
||||
var log = [];
|
||||
angular.service('svc1', function() { log.push('svc1'); }, {$eager: true});
|
||||
angular.scope();
|
||||
expect(log).toEqual(['svc1']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isDate', function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue