AngularJS制作了一个简单的组

时间:2018-03-05 16:08:55

标签: javascript angularjs filter group-by

我在AngularJS中遇到一个小组的麻烦。 这是我的代码:

 <div class="ibox float-e-margins collapsed">
     <div ng-repeat="(key, value) in costList | groupBy: 'Month'">
            {{group}}
          <ul>
             <li ng-repeat="costList in value">

             </li>
           </ul>
      </div>
</div>

当我在代码中添加| groupBy: 'Month'时,它会显示错误:

Error: [$injector:unpr] http://errors.angularjs.org/1.6.6/$injector/unpr?p0=groupByFilterProvider%20%3C-%20groupByFilter
at angularjs?v=3IGOL90Rnusy-QTWOoBPXNF6utfbZEM46kAny3Khxb81:14
at angularjs?v=3IGOL90Rnusy-QTWOoBPXNF6utfbZEM46kAny3Khxb81:53
at Object.d [as get] (angularjs?v=3IGOL90Rnusy-QTWOoBPXNF6utfbZEM46kAny3Khxb81:50)
at angularjs?v=3IGOL90Rnusy-QTWOoBPXNF6utfbZEM46kAny3Khxb81:53
at Object.d [as get] (angularjs?v=3IGOL90Rnusy-QTWOoBPXNF6utfbZEM46kAny3Khxb81:50)
at angularjs?v=3IGOL90Rnusy-QTWOoBPXNF6utfbZEM46kAny3Khxb81:173
at V (angularjs?v=3IGOL90Rnusy-QTWOoBPXNF6utfbZEM46kAny3Khxb81:134)
at angularjs?v=3IGOL90Rnusy-QTWOoBPXNF6utfbZEM46kAny3Khxb81:132
at p (angularjs?v=3IGOL90Rnusy-QTWOoBPXNF6utfbZEM46kAny3Khxb81:15)
at V (angularjs?v=3IGOL90Rnusy-QTWOoBPXNF6utfbZEM46kAny3Khxb81:132) "<!-- ngRepeat: (key, value) in costList | groupBy: '[Month]' -->"

我认为我缺少一些依赖项,但我不知道我遗漏了哪个文件。

js文件如下,

var app = angular.module('BusinessTripBudget', ['angular.filter']);
   app.controller('Budget', ["$scope", "$http", "$window", "$compile", "$q", 
     function ($scope, $http, $window, $compile, $q) {

        //Here I put the code that retrieves data

   }]);

我正在使用AngularJS v1.6.6

这是我的脚本命令:

            jquery-ui.min.js
            angular.min.js
            MyCustomJS.js

1 个答案:

答案 0 :(得分:1)

错误显示缺少角度滤波器模块

请按照以下步骤进行 在包含Angular本身之后,在index.html中包含angular-filter.js(或angular-filter.min.js)。

添加&#39; angular.filter&#39;到主模块的依赖项列表。

按照步骤添加https://github.com/a8m/angular-filter

中的依赖项