Stack Overflow на русском Asked by Yumie on January 6, 2022
Не совсем понимаю как убрать ошибку такого типа:
Error: [$injector:unpr] Unknown provider: startFromFilterProvider <-
startFromFilter
Прикладываю код объявления модуля, контроллера и фильтров:
angular.module('dealersApp.history', ['ui.router']).config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('history', {
url:"/history",
templateUrl: 'history/history.html',
controller: 'HistoryController'
});
}]).controller('HistoryController', ['$rootScope','$scope','$location','Client', function ($rootScope,$scope,$location,Client) {
//...
}]).filter('unique', function() {
return function(collection, keyname) {
var output = [],
keys = [];
angular.forEach(collection, function(item) {
var key = '';
if(keyname === 'Date') {
if(typeof item[keyname] !== "undefined") {
key = item[keyname].replace(/T[d:]+/, '');
}
} else {
key = item[keyname];
}
if(keys.indexOf(key) === -1 && typeof key !== "undefined") {
keys.push(key);
output.push(item);
}
});
return output;
};
}).filter('startFrom', function() {
return function(input, start) {
start = +start;
return input.slice(start);
};
});
Также есть общий модуль со всеми зависимостями:
angular.module('dealersApp', [
'ui.router',
'ngResource',
'dealersApp.login',
'dealersApp.home',
'dealersApp.catalog',
'dealersApp.recovery',
'dealersApp.actions',
'dealersApp.sale',
'dealersApp.new',
'dealersApp.basket',
'dealersApp.settings',
'dealersApp.history',
'dealersApp.edit',
'dealersApp.refunds',
'dealersApp.claims',
'dealersApp.reclamations',
'dealersApp.invoices',
'dealersApp.integrationApi',
'authService',
'lbServices',
'angucomplete-alt'
]).config(['$stateProvider', '$locationProvider','$urlRouterProvider','LoopBackResourceProvider','$httpProvider','$rootScopeProvider', function ($stateProvider, $locationProvider,$urlRouterProvider,LoopBackResourceProvider,$httpProvider,$rootScope) {
$stateProvider.state('logout', {
url:"/logout",
template: '',
controller: ['User', '$location','$rootScope',function(user,$location,$rootScope){
user.logout();
$rootScope.user = null;
user.isAuthenticated();
$location.path('/login'); //send to login page
}]
}).state('404', {
url:"/404",
template: '<div class="error-404">404 <br/>Страница не найдена</div>',
controller: ''
});
$urlRouterProvider.when('', '/').otherwise('/404');
LoopBackResourceProvider.setUrlBase(baseUrl+'/api/');
$httpProvider.interceptors.push(function($q, $location, LoopBackAuth ,$rootScope) {
return {
responseError: function(rejection) {
if (rejection.status == 401) {
LoopBackAuth.clearUser();
LoopBackAuth.clearStorage();
$rootScope.user = null;
$location.nextAfterLogin = $location.path();
$location.path('/login');
}
return $q.reject(rejection);
}
};
});
}])
template:
<select ng-model="orderStatus" class="filter" ng-change="filterOrders('Status', orderStatus); currentPage = 0;">
<option value="">Select status</option>
<option ng-repeat="order in infoOrders | unique : 'Status'" value="{{order.Status}}">{{ order.Status }}</option>
</select>
<select ng-model="orderDate" class="filter" ng-change="filterOrders('Date', orderDate); currentPage = 0;">
<option value="">Select date</option>
<option ng-repeat="order in infoOrders | unique : 'Date'" value="{{order.Date | date:'yyyy-MM-dd' }}">{{ order.Date | date:'yyyy-MM-dd'}}</option>
</select>
...
<div ng-repeat="order in orders | startFrom: startingItem() | limitTo: itemsPerPage" class="item_block">
<div class="head-order flex" ng-click="slider_open = !slider_open">
<div class="fl-1">{{order.Number || "Номер еще не присвоен."}}</div>
<div class="fl-1">{{order.Date | date:'yyyy-MM-dd' || order.created | date:'yyyy-MM-dd'}}</div>
</div></div>
В итоге причина оказалась в кешировании страницы. Код рабочий.
Answered by Yumie on January 6, 2022
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP