Search code examples
angularjsangularjs-scope

Angular 1.6 $injector: unpr error


I got some data coming from an API and want to list it on a table. Angular 1.6

I'm getting the error:

 Error: [$injector:unpr] Unknown provider: nameFilterProvider <- nameFilter

This is my angular controller:

$app.controller('partnersAnalyticsController', ['$rootScope', '$scope', '$http',
    function ($rootScope, $scope, $http) {
      $scope.$on('yahoo_analytics_changed', function (e, args) {

        $http.get("https://api-metrics....", {
            headers: {'Authorization': 'Bearer ...'}})
        .then(function(response) {
            $scope.testeYahoo = response.data.rows
           console.log(response.data)
        });
        $scope.groupType = args.data.period;
        $scope.currentPage = 1;
    });
});

This is my table:

    <tr dir-paginate="dado in testeYahoo | itemsPerPage: pageSize" current-page="currentPage" pagination-id="testeYahoo" style="cursor:default">
      <td>{{dado.dateTime}}</td>
      <td ng-if="groupType=='day'">x</td>
      <td>{{dado.app|name}}</td>
      <td>x</td>
      <td>{{dado.impressions}}</td>
      <td>$ {{dado.eCPM}}</td>
      <td>$ {{dado.revenueInUSD}}</td>
      <td>x</td>
    </tr>
    </tbody>
  </table>

  <div class="text-center">
    <dir-pagination-controls boundary-links="true" template-url="dirPagination.tpl.html" pagination-id="testeYahoo"></dir-pagination-controls>
  </div>

EDIT

This is array to show:

adNetwork|name: "Gemini"
app|name : "Estadão / Banner Horizontal"
clicks: 1085

Solution

  • You are using <td>{{dado.app|name}}</td> which means 'use the filter name'.

    Check in your code if you are correctly registering this filter, it should be something like :

    angular.module('myApp').filter('name', ['$filter', function($filter) {
         //some code for the filter
    }])