Reputation: 35925
I would like that all my $scope
objects contain a specific helper method that I use to retrieve data like $scope.getData('member.submember.othermember')
otherwise I would have to do $scope['member']['submember']['othermember']
.
The idea is to add this .getData
method to all the created $scope
objects by default.
Is there any extensibility point where I may add that?
Upvotes: 1
Views: 142
Reputation: 222528
Angular scopes use JS prototypal inheritance, it is possible to add custom method to all scopes (in addition to existing $ methods) with
$rootScope.constructor.prototype.$getData = function () { ... };
Upvotes: 2