我想为菜单下拉菜单构建简单的切换菜单功能。我从堆栈帖子中获取了一些代码,但它与标签功能更相关。
那么我们怎样才能做到这一点。如果我为此目的使用jquery,会不会有任何问题。
http://jsfiddle.net/3G7Kd/107/
<div ng-app='app' class="filters_ct" ng-controller="selectFilter">
<ul class="nav">
<li ng-repeat="filter in filters" ng-click="select($index)" ng-class="{sel: $index == selected}">
<span class="filters_ct_status"></span>
{{filter.name}}
<ul class="subul" ng-if=filter.lists.length>
<li ng-repeat="list in filter.lists">
{{list}}
</li>
</ul>
</li>
</ul>
</div>
角
var app = angular.module('app', []);
app.controller('selectFilter', function($scope) {
$scope.filters = [
{
"name": "service",
'lists': ['service a','service b','service c','service d']
},
{
'name': "about us",
'lists': ['about us a','about us b','about us c','about us d']
},
{
'name': "product",
'lists': ['product a','product b','product c','product d']
},
{
'name': "more",
'lists': ['more a','more b','more c','more d']
}
];
$scope.selected = 0;
$scope.select= function(index) {
$scope.selected = index;
};
});
答案 0 :(得分:3)