我尝试将accordion指令与我自己的模板一起使用。我使用以下内容:
<accordion close-others="1">
<accordion-group heading="First" is-open="1" template-url="template/accordion/accordion-mytemplate.html">
First
</accordion-group>
<accordion-group heading="Second" template-url="template/accordion/accordion-mytemplate.html">
Second
</accordion-group>
</accordion>
在JavaScript文件中定义模板:
angular.module("template/accordion/accordion-mytemplate.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("template/accordion/accordion-mytemplate.html",
"<div class=\"panel panel-default\">\n" +
"<div class=\"panel-heading\">\n" +
"<h1 class=\"panel-title\">\n" +
"TEST: <a href=\"javascript:void(0)\" tabindex=\"0\" class=\"accordion-toggle\" ng-click=\"toggleOpen()\" accordion-transclude=\"heading\"><span ng-class=\"{'text-muted': isDisabled}\">{{heading}}</span></a>\n" +
"</h1>\n" +
"</div>\n" +
"<div class=\"panel-collapse collapse\" collapse=\"!isOpen\">\n" +
" <div class=\"panel-body\" ng-transclude></div>\n" +
"</div>\n" +
"</div>\n" +
"");
}]);
并且不幸的是,当我使用$ templateCache或者我直接在 template / accordion / accordion-mytemplate.html 文件中保存模板时,它对这两项工作都不起作用(这种方式是由我)。
有人可以形容我如何将ui.bootstrap.accordion与自定义模板一起使用,以及为什么template-url属性不起作用?