我试图在ng-repeat列表中使用折叠。但它只显示列表的第一个元素。如何让它显示所有元素?
menuVertical.directive.js
lapply(outdm, function(x) strsplit(x$mod, split = "\\|"))
menuVertical.html
(function () {
'use strict';
angular
.module("academico")
.directive("menuVertical", menuVertical);
function menuVertical() {
return {
restrict: 'E',
templateUrl: "components/ui/menuVertical/menuVertical.html?v="+ globalgsvapp,
scope:{
datos: '@',
clickOn: '&',
},
link: function(scope, elem, attrs){
scope.form = {};
scope.form.datos = '';
if (scope.datos) { // cambiar el texto de Resultados
scope.form.datos = JSON.parse(scope.datos);
}
}
}
}
})();
controller.js
<div ng-repeat="f in form.datos track by $index">
<a href="{{f.href}}" class="list-group-item"
id="datos_estmenu"
style="background-color: #2b3e50; color: #FFFFFF;"
data-toggle="collapse"
data-target="#{{f.id}}"
data-parent="#sidebar" >
<i class="{{f.icono}}" > </i>{{f.titulo}}
<i class="fa fa-caret-down pull-right"></i>
</a>
<div id="{{f.id}}" ng-repeat="f1 in f.submenu track by $index" >
<a href="" data-toggle="tooltip"
data-placement="right" class="list-group-item"
ng-click="self.limpiaSes(); self.newPass()">{{f1.tit_submenu}}
<i class="fa fa-angle-right pull-right"></i>
</a>
</div>
</div>
答案 0 :(得分:0)
您使用的是错误的范围变量"form.datos"
。如果您的控制器包含$scope.datos
,那么在ng-repeat中您可以使用如下:
<div ng-repeat="f in datos track by $index">
另外,请不要忘记添加ng-controller
。
所以,总结是:
- HTML更改中的
在控制器中: 将
self.datos
替换为$scope.datos
:
form.datos
到datos
<div ng-repeat="f in datos track by $index">
- 在HTML中添加控制器:
醇>
<div ng-controller = "YourController" ></div>`
<div ng-repeat="f in datos track by $index"></div>`
</div>