Smitha Smitha - 1 month ago 14
AngularJS Question

Angular UI tab custom directive has template issues

I have the following snippet in a single file and I get the following erro:



Template for directive 'uibTabset' must have exactly one root element /my-tabs.html







<script type="text/ng-template" id="/my-tabs.html</script>
..

<script type="text/javascript">
angular.module('checkinapp', ['ngAnimate', 'ui.bootstrap']);
angular.module('checkinapp').controller('TabsDemoCtrl', function($scope, $window) {
// or here... $scope.indextab = 1
});
</script>

....
<section class="my-tabs" ng-controller="TabsDemoCtrl" ng-init="indextab = 1">
<uib-tabset active="indextab" template-url="/my-tabs.html">
<uib-tab index="0" heading="Static title" class="col-xs-4 col-sm-4 col-md-4 col-lg-4">Static First</uib-tab>
<uib-tab index="1" heading="Static title1" class="col-xs-4 col-sm-4 col-md-4 col-lg-4">Static Second</uib-tab>
<uib-tab index="2" heading="Static title2" active="true" class="col-xs-4 col-sm-4 col-md-4 col-lg-4">Static Third</uib-tab>
</uib-tabset>
</section>





How do I resolve it?

Thanks

Answer

Change

<script type="text/ng-template" id="/my-tabs.html</script>
...
<uib-tabset active="indextab" template-url="/my-tabs.html">

to

<script type="text/ng-template" id="my-tabs.html">
   <div>fill your template here</div>
</script>
...
<uib-tabset active="indextab" template-url="my-tabs.html">