我的 Angular 应用程序有这样的代码来添加服务:
stApp.factory('entityService', ['$http', '$q', '$resource', function (
$http, $q, $resource) {
现在我刚刚添加了一个这样的过滤器:
stApp.filter('truncate', function () {
return function (value, wordwise, max, tail) {
if (!value) return '';
当我调试时,我发现它在 stApp.filter 行中读取。
但是,当我运行我的代码时:
{{modal.data.text | trunacate:true:15:' ...'}}
我收到一条消息说:
Error: Unknown provider: trunacateFilterProvider <- trunacateFilter
at Error (<anonymous>)
at http://127.0.0.1:81/Scripts/angular.js:2714:19
at Object.getService [as get] (http://127.0.0.1:81/Scripts/angular.js:2840:39)
at http://127.0.0.1:81/Scripts/angular.js:2719:45
at Object.getService [as get] (http://127.0.0.1:81/Scripts/angular.js:2840:39)
at $get (http://127.0.0.1:81/Scripts/angular.js:10451:24)
at filter (http://127.0.0.1:81/Scripts/angular.js:6590:14)
at _filterChain (http://127.0.0.1:81/Scripts/angular.js:6581:41)
at statements (http://127.0.0.1:81/Scripts/angular.js:6557:25)
at parser (http://127.0.0.1:81/Scripts/angular.js:6484:13)
有人可以指出我正确的方向吗?我认为我的代码没问题,无法理解为什么我会收到此消息。