Reputation: 416
I'm attempting to use a custom filter in the ng-repeat but facing an error as below.
Error: $injector:unpr Unknown Provider Unknown provider: $scopeProvider <- $scope <- ngRepeatFinishFilter
Here's my HTML
<tr ng-repeat="person in (sc.people|ngRepeatFinish)| filter:f">
Here's my Controller
(function () {
"use strict";
var app = angular.module('MYAPP');
app.controller("SearchController", ["mainSearch", "$routeParams", "$scope", SearchController]);
app.filter('ngRepeatFinish', function ($timeout, $scope) {
return function (data) {
//var me = this;
var flagProperty = '__finishedRendering__';
if (!data[flagProperty]) {
Object.defineProperty(
data,
flagProperty,
{ enumerable: false, configurable: true, writable: false, value: {} });
$timeout(function () {
delete data[flagProperty];
$scope.setNRCGroupColor();
//me.$emit('ngRepeatFinished');
}, 0, false);
}
return data;
};
});
function SearchController(mainSearch, $routeParams, $scope) {
//
}
}());
Upvotes: 1
Views: 914
Reputation: 3629
Injecting $scope
in filters is giving you error, try using your scope like:
app.filter('ngRepeatFinish', function ($timeout) {
return function (data, scope) {
// scope here will give you all access to $scope
// your other code
};
});
Upvotes: 0