mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-28 12:55:48 +08:00
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:
@@ -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'; });
|
||||
|
||||
Reference in New Issue
Block a user