未知提供者:accordionDirectiveProvider
Unknown provider: accordionDirectiveProvider
谁能帮我找出我的错误在哪里?我使用 this example 在我的页面上构建可排序的手风琴。示例运行良好,但我已将此代码放入我的应用程序并出现此错误
angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to: Error: [$injector:unpr] Unknown
provider: accordionDirectiveProvider
http://errors.angularjs.org/1.5.7/$injector/unpr?p0=accordionDirectiveProvider
at http://localhost:63342/myapp%202.0/libs/angular/angular.js:68:20
at http://localhost:63342/myapp%202.0/libs/angular/angular.js:4502:27
at Object.getService [as get] (http://localhost:63342/myapp%202.0/libs/angular/angular.js:4655:53)
at Object.decorator (http://localhost:63342/myapp%202.0/libs/angular/angular.js:4577:49)
at http://localhost:63342/myapp%202.0/js/app/app.js:56:18
at Object.invoke (http://localhost:63342/myapp%202.0/libs/angular/angular.js:4709:31)
at runInvokeQueue (http://localhost:63342/myapp%202.0/libs/angular/angular.js:4602:49)
at http://localhost:63342/myapp%202.0/libs/angular/angular.js:4611:25
at forEach (http://localhost:63342/myapp%202.0/libs/angular/angular.js:321:34)
at loadModules (http://localhost:63342/myapp%202.0/libs/angular/angular.js:4592:13)
http://errors.angularjs.org/1.5.7/$injector/modulerr?p0=app&p1=Error%3A%20%…localhost%3A63342%2Fmyapp%25202.0%2Flibs%2Fangular%2Fangular.js%3A4592%3A13)
从这一行我可以看出我的提供者有问题
http://localhost:63342/myapp%202.0/js/app/app.js:56:18 at Object.invoke
.config(['$provide', function ($provide){
$provide.decorator('accordionDirective', function($delegate) {
var directive = $delegate[0];
directive.replace = true;
return $delegate;
});
}])
但是无论我从该提供商那里清除我的代码,手风琴都停止工作。我的错误在哪里?我很抱歉,但无法在 plunker 中捕获此错误,因此请将我的代码放在下面
(function () {
window.app = angular.module('app', ['ngRoute','ngAnimate', 'ui.bootstrap', 'ui.sortable', 'ngSanitize',
'ngTouch',
'ui.grid',
'ui.grid.exporter',
'ui.grid.selection',
'ui.grid.pagination',
'ui.grid.saveState',
'ui.grid.cellNav',
'ui.grid.resizeColumns',
'ui.grid.moveColumns',
'ui.grid.pinning',
'ui.grid.grouping',
'ui.grid.autoResize',
'ui.grid.edit',
'ui.grid.rowEdit'
])
.run(['$rootScope', function($rootScope) {
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
$rootScope.title = current.$$route.title;
});
}])
.config(['$httpProvider', function ($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common["X-Requested-With"];
}])
.config(['$routeProvider',
function($routeProvider) {
$routeProvider
.when('/', {
title: " ",
controller: 'homeCtrl'
})
.when('/page', {
title: 'GRID',
templateUrl: 'html/pages/grid.html',
controller: 'gridCtrl'
})
.when('/designer', {
title: 'Design Grid',
templateUrl: 'html/pages/designer.html',
controller: 'designerCtrl'
})
.otherwise({
redirectTo: '/'
});
}])
.config(['$provide', function ($provide){
$provide.decorator('accordionDirective', function($delegate) {
var directive = $delegate[0];
directive.replace = true;
return $delegate;
});
}])
.filter('makeUppercase', function () {
return function (item) {
var space = item.replace(/\./g, " ");
var result = space.replace(/([A-Z])/g, " ");
return result.charAt(0).toUpperCase() + result.slice(1)
};
})
}());
html
<uib-accordion ui-sortable="sortableOptions" ng-model="panels">
<uib-accordion-group ng-repeat="panel in panels">
<uib-accordion-heading>
<div class="handle"><i class="fa fa-arrows pull-left"></i></div>
<span class="panel-title-left">{{panel.heading}}</span>
<i class="caret pull-right"></i>
</uib-accordion-heading>
<div ng-include=" panel.url "></div>
</uib-accordion-group>
</uib-accordion>
如果您使用 uib-tools 1.+,可能会出现此错误。在最新版本中,他们已将指令名称从 'accordion' 更改为 'uibAccordion',因此您可能必须使用 'uibAccordionDirective'。参见示例
.config(['$provide', function ($provide){
$provide.decorator('uibAccordionDirective', function($delegate) {
var directive = $delegate[0];
directive.replace = true;
return $delegate;
});
}])
谁能帮我找出我的错误在哪里?我使用 this example 在我的页面上构建可排序的手风琴。示例运行良好,但我已将此代码放入我的应用程序并出现此错误
angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to: Error: [$injector:unpr] Unknown provider: accordionDirectiveProvider http://errors.angularjs.org/1.5.7/$injector/unpr?p0=accordionDirectiveProvider at http://localhost:63342/myapp%202.0/libs/angular/angular.js:68:20 at http://localhost:63342/myapp%202.0/libs/angular/angular.js:4502:27 at Object.getService [as get] (http://localhost:63342/myapp%202.0/libs/angular/angular.js:4655:53) at Object.decorator (http://localhost:63342/myapp%202.0/libs/angular/angular.js:4577:49) at http://localhost:63342/myapp%202.0/js/app/app.js:56:18 at Object.invoke (http://localhost:63342/myapp%202.0/libs/angular/angular.js:4709:31) at runInvokeQueue (http://localhost:63342/myapp%202.0/libs/angular/angular.js:4602:49) at http://localhost:63342/myapp%202.0/libs/angular/angular.js:4611:25 at forEach (http://localhost:63342/myapp%202.0/libs/angular/angular.js:321:34) at loadModules (http://localhost:63342/myapp%202.0/libs/angular/angular.js:4592:13) http://errors.angularjs.org/1.5.7/$injector/modulerr?p0=app&p1=Error%3A%20%…localhost%3A63342%2Fmyapp%25202.0%2Flibs%2Fangular%2Fangular.js%3A4592%3A13)
从这一行我可以看出我的提供者有问题
http://localhost:63342/myapp%202.0/js/app/app.js:56:18 at Object.invoke
.config(['$provide', function ($provide){
$provide.decorator('accordionDirective', function($delegate) {
var directive = $delegate[0];
directive.replace = true;
return $delegate;
});
}])
但是无论我从该提供商那里清除我的代码,手风琴都停止工作。我的错误在哪里?我很抱歉,但无法在 plunker 中捕获此错误,因此请将我的代码放在下面
(function () {
window.app = angular.module('app', ['ngRoute','ngAnimate', 'ui.bootstrap', 'ui.sortable', 'ngSanitize',
'ngTouch',
'ui.grid',
'ui.grid.exporter',
'ui.grid.selection',
'ui.grid.pagination',
'ui.grid.saveState',
'ui.grid.cellNav',
'ui.grid.resizeColumns',
'ui.grid.moveColumns',
'ui.grid.pinning',
'ui.grid.grouping',
'ui.grid.autoResize',
'ui.grid.edit',
'ui.grid.rowEdit'
])
.run(['$rootScope', function($rootScope) {
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
$rootScope.title = current.$$route.title;
});
}])
.config(['$httpProvider', function ($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common["X-Requested-With"];
}])
.config(['$routeProvider',
function($routeProvider) {
$routeProvider
.when('/', {
title: " ",
controller: 'homeCtrl'
})
.when('/page', {
title: 'GRID',
templateUrl: 'html/pages/grid.html',
controller: 'gridCtrl'
})
.when('/designer', {
title: 'Design Grid',
templateUrl: 'html/pages/designer.html',
controller: 'designerCtrl'
})
.otherwise({
redirectTo: '/'
});
}])
.config(['$provide', function ($provide){
$provide.decorator('accordionDirective', function($delegate) {
var directive = $delegate[0];
directive.replace = true;
return $delegate;
});
}])
.filter('makeUppercase', function () {
return function (item) {
var space = item.replace(/\./g, " ");
var result = space.replace(/([A-Z])/g, " ");
return result.charAt(0).toUpperCase() + result.slice(1)
};
})
}());
html
<uib-accordion ui-sortable="sortableOptions" ng-model="panels">
<uib-accordion-group ng-repeat="panel in panels">
<uib-accordion-heading>
<div class="handle"><i class="fa fa-arrows pull-left"></i></div>
<span class="panel-title-left">{{panel.heading}}</span>
<i class="caret pull-right"></i>
</uib-accordion-heading>
<div ng-include=" panel.url "></div>
</uib-accordion-group>
</uib-accordion>
如果您使用 uib-tools 1.+,可能会出现此错误。在最新版本中,他们已将指令名称从 'accordion' 更改为 'uibAccordion',因此您可能必须使用 'uibAccordionDirective'。参见示例
.config(['$provide', function ($provide){
$provide.decorator('uibAccordionDirective', function($delegate) {
var directive = $delegate[0];
directive.replace = true;
return $delegate;
});
}])