How do I use decorators without having access to object.defineProperty?
I am looking into the shims available:
but in case those don't pass testing, is there another way decorators were intended to work?
I am using the decorator for $onRootScope.
I am using angular 1.08. I need compatibility with IE7.
Update
I have tried out a few methods that seem to work but I don't know the difference between them: plunkr
var app = angular.module('plunker', []);
app.config(['$provide', function($provide){
$provide.decorator('$rootScope', ['$delegate', function($delegate){
$delegate.a = 1;
$delegate.constructor.prototype.b = 2;
Object.defineProperty($delegate.constructor.prototype, 'c', {
value: 3
});
return $delegate;
}]);
}]);
app.controller('MainCtrl', function($rootScope, $scope) {
console.log($rootScope); //reveals `a` property
console.log($rootScope.constructor.prototype); //=> {b:2, c:3}
console.log($rootScope.a); //=> 1
console.log($rootScope.b); //=> 2
console.log($rootScope.c); //=> 3
$scope.name = 'World';
});
Thank You.