AngularJS制作了一个简单的组

问题描述 投票:0回答:1

我在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
javascript angularjs filter group-by
1个回答
1
投票

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

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

将'angular.filter'添加到主模块的依赖项列表中。

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

© www.soinside.com 2019 - 2024. All rights reserved.