0
我是新的angularjs,我試圖創建一個從字符串中刪除空格的過濾器。在angularjs中添加一個過濾器
removeSpaces.js
angular.module('filters.stringUtils', [])
.filter('removeSpaces', [function() {
return function(string) {
if (!angular.isString(string)) {
return string;
}
return string.replace(/[\s]/g, '');
};
}])
home.html的
<div ng-controller="ItemController">
<p ng-repeat="item in items">
<a href="/items/{{ item.item_name | removeSpaces }}">{{ item.item_name }}</a>
</p>
itemcontroller.js
angular.module('myApp').controller('ItemController', [
'$scope', 'Services', '$http','removeSpaces', function($scope, Services, $http,removeSpaces) {
$http.defaults.headers.common['Accept'] = 'application/json';
return $scope.services = Services.query();
}
]);
我得到這個錯誤:
Unknown provider: removeSpacesFilterProvider <- removeSpacesFilter
是filter.stringUtils模塊中對myApp的依賴性注意什麼? – LionC