不应该这样:
<ul class="dropdown-menu">
<li><a href ng-click="app.selectTab(1)">Cranves-Sales</a></li>
<li><a href ng-click="app.selectTab(2)">Epagny</a></li>
</ul>
与此相同:
<ul class="dropdown-menu">
<li ng-repeat="magasin in app.magasins">
<a ng-repeat="magasin in app.magasins" href ng-click="app.selectTab({{magasin.tab}})">{{magasin.name}}</a>
</li>
</ul>
我在页面主体上有角度控制器,因为它是一个小网站,当我使用app.selectTab(1)时它工作,但它不应该是一个问题因为我&#39; m使用ng-show="app.isSelectedTab({{magasin.tab}})"
这是我的app控制器:
app.controller('appController', function () {
this.products = products;
this.magasins = magasins;
//PAGE
this.page = 2;
this.selectPage = function (setPage) {
this.page = setPage;
};
this.isSelectedPage = function (checkPage) {
return this.page === checkPage;
};
//TAB
this.tab = 2;
this.selectTab = function (setTab) {
this.page = 2;
this.tab = setTab;
};
this.isSelectedTab = function (checkTab) {
return this.tab === checkTab;
};
});
var magasins = [{
name: 'Cranves Sales',
tab: '1'
}, {
name: 'Epagny',
tab: '2'
} ]
}
答案 0 :(得分:5)
ngRepeat
上只需{1} {{}},当您将值传递给<li>
时,您不需要ngClick
{{}}