错误:[$ injector:unpr] rangeFilterProvider中的错误

时间:2018-02-22 17:16:06

标签: angularjs angularjs-ng-repeat angularjs-filter

我正在开发一个angularjs应用程序,我尝试使用ng-repeat指令,但是使用范围过滤器,但根本不起作用。

这是代码:

<div class="col-md-offset-2 row" ng-repeat="n in []|range:5">
    <div class="col-md-offset-1 col-md-10">
        <input type="email" name="email[]" ng-model="proveedor.emails[{{$index}}]" placeholder="usuario@dominio.com" class="form-control"/>
    </div>
    <div class="1">
        <a href="javascript:;" data-repeater-delete="" class="btn btn-danger">
            <i class="fa fa-close"></i>
        </a>
    </div>
</div>

如果我删除了rage过滤器并将表达式替换为目标数组,则一切正常。

这是错误

Error: [$injector:unpr] http://errors.angularjs.org/1.6.9/$injector/unpr?p0=rangeFilterProvider%20%3C-%20rangeFilter
Stack trace:
K/<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:7:76
gb/p.$injector<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:46:64
d@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:43:309
gb/s<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:46:124
d@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:43:309
ed/this.$get</<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:166:472
W@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:128:106
W/<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:126:172
r@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:8:5
W@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:126:151
compile@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:241:194
parse@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:266:183
f@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:131:214
$watchCollection@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:147:226
compile/<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:317:29
Ra/<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:17:132
va@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:85:426
p@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:71:93
f@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:388
f@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:405
f@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:405
f@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:405
p@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:71:33
f@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:388
f@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:405
f@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:405
f@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:405
da/<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:11
compile/<@http://localhost/sicocme-angular/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js:7:24939
Ra/<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:17:132
va@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:85:426
p@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:71:93
f@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:388
da/<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:62:11
W/<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:67:138
l@http://localhost/sicocme-angular/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js:7:23860
compile/</<@http://localhost/sicocme-angular/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js:7:24280
$broadcast@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:153:403
w/z.transitionTo/z.transition<@http://localhost/sicocme-angular/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js:7:19271
h/<@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:137:167
$digest@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:148:130
$apply@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:151:353
l@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:103:165
t@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:108:228
yg/</A.onload@http://localhost/sicocme-angular/assets/bower_components/angular/angular.min.js:109:139
 <!-- ngRepeat: n in []|range:5 --> angular.js:14800:15

我还阅读了angularjs错误网站中的文档,但我不知道为什么提供者不知道。

我的主要模块

var SicocmeApp = angular.module("SicocmeApp", [
    "ui.router",
    "ui.bootstrap",
    "oc.lazyLoad",
    "ngSanitize"
])

外部js中的控制器(正常加载)

angular.module('SicocmeApp').controller('AdicionarProveedorController', function ($rootScope, $scope, $http, $timeout) {

});

提前致谢!

1 个答案:

答案 0 :(得分:0)

根据angularjs docs,Range不是原生过滤器。这就是它给出错误的原因。由于无法找到该过滤器。

检查this doc for what is available.您始终可以创建一个新的过滤器,使其成为&#34;范围&#34;使用$ filter工作。