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.
This commit is contained in:
Vojta Jina
2013-10-16 12:14:44 -07:00
committed by Igor Minar
parent dba566a96d
commit c22adbf160
2 changed files with 11 additions and 1 deletions

View File

@@ -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'; });