這必須是一個非常愚蠢的問題;然而,我正在學習角度,並認爲我有一切工作,但事實並非如此。ng-repeat和json不會顯示在li的子頁面中
我沒有通過終端或控制檯收到任何錯誤。我的第一個李的列表正在顯示。我試圖讓下面的子頁面填充;但是,我什麼也沒有得到。
下面是HTML:
<nav class="menu-wrap">
<ul>
<li ng-repeat="link in links" ng-class="{true: 'dropDown'}[dropDown]">
<a ng-href="{{link.href}}">
<i class="{{link.icon}}"></i>
{{link.name}}
<span class="{{link.arrowDown}}" ng-click="dropDown != dropDown"></span>
</a>
<ul>
<li ng-repeat="child in links.child">
<a ng-href="{{links.child.href}}">
<i class="{{links.child.icon}}"></i>
{{links.child.name}}
</a>
</li>
</ul>
</li>
</ul>
</nav>
控制器:
angular.module('App')
.controller('PrimaryMenuCtrl', function ($scope) {
// Set menu to closed
$scope.open = false;
$scope.dropDown = false;
// Toggle open class on click
$scope.toggle = function() {
$scope.open = !$scope.open;
$scope.dropDown = !$scope.dropDown;
};
$scope.links = [{
name: 'Dashboard',
icon: 'fa fa-user',
href: '#',
arrowUp: 'fa fa-angle-up',
arrowDown: 'fa fa-angle-down',
child: [{
name: 'Child Page',
icon: 'fa fa-user',
href: '#'
}, {
name: 'Child Page',
icon: 'fa fa-user',
href: '#'
}, {
name: 'Child Page',
icon: 'fa fa-user',
href: '#'
}]
}, {
name: 'Post',
icon: 'fa fa-user',
href: '#'
}, {
name: 'Media',
icon: 'fa fa-user',
href: '#'
}, {
name: 'Pages',
icon: 'fa fa-user',
href: '#'
}, {
name: 'Comments',
icon: 'fa fa-user',
href: '#',
arrowUp: 'fa fa-angle-up',
arrowDown: 'fa fa-angle-down',
child: [{
name: 'Child Page',
icon: 'fa fa-user',
href: '#'
}, {
name: 'Child Page',
icon: 'fa fa-user',
href: '#'
}, {
name: 'Child Page',
icon: 'fa fa-user',
href: '#'
}]
}, {
name: 'Appearance',
icon: 'fa fa-user',
href: '#'
}, {
name: 'Plugins',
icon: 'fa fa-user',
href: '#'
}, {
name: 'Users',
icon: 'fa fa-user',
href: '#'
}];
});
我是白癡,你是對的。 – zach57