Is there a way to implement decorators without relying on object.defineProperty?
I have explored the shims that are available:
If these options do not work, are there alternative methods for utilizing decorators as intended?
I am specifically using the decorator for $onRootScope.
My framework of choice is angular 1.08 and I require compatibility with IE7.
Update
I have experimented with various techniques that appear to be effective, but I am unsure about their distinctions: 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.