From c22adbf160f32c1839fbb35382b7a8c6bcec2927 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Wed, 16 Oct 2013 12:14:44 -0700 Subject: fix($injector): allow a constructor function to return a function This change makes `$injector.instantiate` (and thus `$provide.service`) to behave the same as native `new` operator. --- test/auto/injectorSpec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/auto') diff --git a/test/auto/injectorSpec.js b/test/auto/injectorSpec.js index 5c186cf1..aea2dee7 100644 --- a/test/auto/injectorSpec.js +++ b/test/auto/injectorSpec.js @@ -788,6 +788,16 @@ describe('injector', function() { }); + it('should allow constructor to return a function', function() { + var fn = function() {}; + var Class = function() { + return fn; + }; + + expect($injector.instantiate(Class)).toBe(fn); + }); + + it('should handle constructor exception', function() { expect(function() { $injector.instantiate(function() { throw 'MyError'; }); -- cgit v1.2.3