Angular-UI中的动态标签失败了吗?

时间:2014-07-05 08:52:26

标签: javascript angularjs angular-ui angular-ui-bootstrap angularjs-controller

创建了这个简单的测试用例,显示发生的错误:

HTML

<tabset ng-repeat="tab in tabs">
    <tab heading="{{tab.title}}">
        <i ng-class="name_to_class[tab.title]"></i>{{tab.title}}
    </tab>
    <tab active="tab.active" disabled="tab.disabled">
        <ul class="list-group">
            <li class="list-group-item" ng-repeat="c in tab.content">{{ c }}</li>
        </ul>
    </tab>
</tabset>

的JavaScript

var TabsDemoCtrl = function ($scope) {
  $scope.name_to_class = {'Dynamic Title 1': 'pull-right', // icons in real-code
                          'Dynamic Title 2': 'pull-right'};
  $scope.tabs = [
    { title:'Dynamic Title 1', content:['foo', 'bar'] },
    { title:'Dynamic Title 2', content:['can', 'haz'] }
  ];
};

plnkr

2 个答案:

答案 0 :(得分:0)

您不能将ng-repeat放在tabsetdocs

ng-repeat放在tab

<强> plnkr

<tabset>
   <tab ng-repeat="tab in tabs" heading="{{tab.title}}" active="tab.active" disabled="tab.disabled"  ng-class="name_to_class[tab.title]">
    <ul class="list-group">
      <li class="list-group-item" ng-repeat="c in tab.content">{{ c }}</li>
    </ul>
  </tab>
</tabset>

答案 1 :(得分:0)

试试这个。 你需要重复标签而不是标签集吗?

        <tabset >
            <tab ng-repeat ="tab in tabs" heading='{{tab.title}}'> 
                <ul class = "list-group" >
                  <li class = "list-group-item" ng-repeat='c in tab.content'> {{c}}
                </ul>
            </tab>
        </tabset>