uib-accordion in angular for list display

时间:2016-02-18 22:51:23

标签: angularjs angularjs-ng-repeat accordion angular-ui-bootstrap

我的索引页有两个div。在第一个< div>我从控制器mController中提取$ scope中的名称。 ng-repeat用于遍历列表以在第一个<中显示电影和名称。 div>。如果用户选择任何名称,我使用ng-model将该对象发送回mController。在我的第二个< div>我正在尝试显示属于Name(parent)的城市(孩子)。

的index.html

<div ng-controller="mController">
<h1>First Part fetch data from controller</h1>
  <uib-accordion close-others="oneAtATime">
      <uib-accordion-group  ng-repeat="x in names" ng-scroll="x in names">
         <uib-accordion-heading>
              {{ x.Movies }}
         </uib-accordion-heading>
      <div class> 
          <a ui-sref="iListPage" ng-repeat="a in x.Heros" ng-scroll="a in x.Heros" ng-model="a" ng-click="value.val=a"> {{ a.Name }} </a>
      </div>
    </uib-accordion-group>
  </uib-accordion>

<h1>Second Part using ui-router call iListPage </h1>
<div class>
  <div class="well">
      <div class="column-nav" ui-view="listColumn"></div>
  </div>
</div>

</div>

我使用ui-router在第二个div中加载iListPage iListPage.html

<h3>iListPage ( work )</h3>
<div ng-controller="mController" >
        <div ng-repeat="x in value.val.Cities">
           {{x.Name}}
        </div>
</div>

<h3>iListPage ( Doesn't works )</h3>
<div>
    <uib-accordion ng-controller="mController">
        <uib-accordion-group close-others="true" ng-repeat="x in value.val.Cities">     
           {{x.Name}}
        </uib-accordion-group>
    </uib-accordion>
</div>

app.js

angular.module('myApp', [])
    .controller('mController', function($scope){

$scope.value = {val:""};
$scope.names = [{ Json Object here }]

});

图像:

enter image description here

无法在uib-accordion中对城市列表进行分组。我在这里错过了什么吗?

0 个答案:

没有答案