use*_*163 7 javascript angularjs angular-ui-bootstrap
使用angular-bootstrap ui时,我在控制台中遇到了以下错误.我有角度1.2.6,bootstrap 3.0和angular-bootstrap 0.10.0.
错误:[$ compile:ctreq]无法找到指令'accordionGroup'所需的控制器'accordion'!
谁知道为什么会这样?我的HTML代码.
<div ui-view>
<accordion-group id="crud-talbe" ng-repeat="grid in grids" heading="{{grid.name}}">
<a ng-click="createNewEntity(grid.name)" class="btn btn-default">create new {{grid.name}}</a>
<div class="crudGridStyle" ng-grid="grid" />
</accordion-group>
Run Code Online (Sandbox Code Playgroud)
从您提供的代码中,您没有包含足够的ui-bootstrap所需的代码.
这看起来像您需要的最小值以及编译器给出错误的原因.
<accordion close-others="oneAtATime">
<accordion-group heading="Static Header, initially expanded" is-open="true">
This content is straight in the template.
</accordion-group>
</accordion>
Run Code Online (Sandbox Code Playgroud)
这是直接从ui-bootstrap网站...手风琴部分.
您可以在accordion group指令的代码中看到手风琴是必需的......
来自github:
// The accordion-group directive indicates a block of html that will expand and collapse in an accordion
.directive('accordionGroup', function() {
return {
require:'^accordion', // We need this directive to be inside an accordion
restrict:'EA',
transclude:true, // It transcludes the contents of the directive into the template
replace: true, // The element containing the directive will be replaced with the template
templateUrl:'template/accordion/accordion-group.html',
scope: {
heading: '@', // Interpolate the heading attribute onto this scope
isOpen: '=?',
isDisabled: '=?'
},
controller: function() {
this.setHeading = function(element) {
this.heading = element;
};
},
link: function(scope, element, attrs, accordionCtrl) {
accordionCtrl.addGroup(scope);
scope.$watch('isOpen', function(value) {
if ( value ) {
accordionCtrl.closeOthers(scope);
}
});
scope.toggleOpen = function() {
if ( !scope.isDisabled ) {
scope.isOpen = !scope.isOpen;
}
};
}
};
})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8453 次 |
最近记录: |