0

I tried to use this simple filter :

App.filter('MyCutFilter', function ()
{
    return function(input)
    {
        return input.replace(/^.*[\\\/]/, '');
    };
})

On a element of ng-repeat like this :

<tr ng-repeat="jf in ctrl.Files" class="tablerow">
    <td><span ng-bind="jf.id"></span></td>
    <td><span class="filename" ng-bind="jf.FileName | MyCutFilter"></span></td>

But i got the following error :

Error: [$injector:unpr] Unknown provider: CutFilterProvider <- CutFilter <- UpFileController

What can i do to correct it ?

Thanks for your help in adavance.

2 Answers2

0

Looking at the error,

Error: [$injector:unpr] Unknown provider: CutFilterProvider <- CutFilter <- UpFileController

It looks like you are trying to inject Cutfilter in a controller named UpFileController. Please, remove the Cutfilter injection from UpFileController.

Saad
  • 942
  • 6
  • 15
0

finally i created my own service like this :

'use strict';

App.factory('UtilsService', [function(nameTable){

    return {
               parseTheseNames: function ParseThesesNames(nameTable){
                    for (var i=0; i < nameTable.length; i++)
                    {
                        //console.log(d[i].upFileName); 
                        nameTable[i].upFileName = nameTable[i].upFileName.replace(/^.*[\\\/]/, '');
                        //console.log("obj " + d[i].upFileName);
                    }
            }
    };

}]);

And i am using it like this :

App.controller('FileController',[..., 'UtilsService',...,
function(..., UtilsService, ...){
.
.
.

function(d){
    UtilsService.parseTheseNames(d);
    self.upFiles = d;
}
.
.
.

I changed what i wanted to get the return of the data directly from a callback to be able to parse the filename earlier.

Thanks for the help and the documentation.