The latest templates of Angular UI Bootstrap don’t play well with Bootstrap 3. A few days back, I tried using the accordion directive of Bootstrap UI and was disappointed with the outcome. It happened so because of the CSS classes. There are significant differences between the CSS classes in version 2.x and 3.0.
In the templates file, there are two templates defined for accordion, accordion.html and accordion-group.html. To make the accordion work with Bootstrap 3, we need to modify the CSS classes used in the directive. Following are the modified templates:
Make these changes and use the accordion directive just as in Bootstrap 2.
Out of other directives, some of them work well with Bootstrap 3 classes, but some of them don’t. Tweaking other directives may not be this easy. But there are ways to make them work.
Update (Jan 2014): Bootstrap UI for Bootstrap 3 is officially released. Refer to the project's source for the template.
Happy coding!
In the templates file, there are two templates defined for accordion, accordion.html and accordion-group.html. To make the accordion work with Bootstrap 3, we need to modify the CSS classes used in the directive. Following are the modified templates:
angular.module("template/accordion/accordion-group.html", []).run(["$templateCache", function ($templateCache) {
$templateCache.put("template/accordion/accordion-group.html",
"<div class=\"panel panel-default\">\n" +
" <div class=\"panel-heading\" ><a class=\"accordion-toggle\" ng-click=\"isOpen = !isOpen\" accordion-transclude=\"heading\">{{heading}}</a></div>\n" +
" <div class=\"panel-collapse collapse in\" collapse=\"!isOpen\">\n" +
" <div class=\"panel-body\" ng-transclude></div> </div>\n" +
"</div>");
}]);
angular.module("template/accordion/accordion.html", []).run(["$templateCache", function ($templateCache) {
$templateCache.put("template/accordion/accordion.html",
"<div class=\"panel-group\" ng-transclude></div>");
}]);
Make these changes and use the accordion directive just as in Bootstrap 2.
<div data-accordion="" data-close-others="true">
<div data-accordion-group="" data-heading="Heading 1">
Contents in first group
</div>
<div data-accordion-group="" data-heading="Heading 2">
Contents in second group
</div>
</div>
Out of other directives, some of them work well with Bootstrap 3 classes, but some of them don’t. Tweaking other directives may not be this easy. But there are ways to make them work.
Update (Jan 2014): Bootstrap UI for Bootstrap 3 is officially released. Refer to the project's source for the template.
Happy coding!