我有問題,我ngclick不工作,因爲我在$ scope.variabel控制器。
<a id="data_table" ng-click="{{ item.target }}"
我認爲目標可以在使用的時候我們稱之爲NG單擊{{item.target}},但沒有工作,我的任何解決方案?由於
,這是我的代碼:
控制器
$scope.states = {};
$scope.states.activeItem = 'nav1';
$scope.items = [{
id: 'nav1',
target: 'home()',
title: 'Home',
icon: 'fa fa-home fa-3x'
}, {
id: 'nav2',
target: 'data_1()',
title: 'Data 1',
icon: 'fa fa-briefcase fa-3x'
}, {
id: 'nav3',
target: 'data_2()',
title: 'Data 2',
icon: 'fa fa-briefcase fa-3x'
},
{
id: 'nav4',
target: 'data_3()',
title: 'Data 3',
icon: 'fa fa-briefcase fa-3x'
},
{
id: 'nav5',
target: 'data_4()',
title: 'Data 4',
icon: 'fa fa-briefcase fa-3x'
},
{
id: 'nav6',
target: 'data_5()',
title: 'Data 5',
icon: 'fa fa-briefcase fa-3x'
}];
查看
<li ng-repeat="item in items" ng-class="{'active': item.id == states.activeItem}" ng-click="states.activeItem = item.id">
<a id="data_table" ng-click="{{ item.target }}">
<i class="{{ item.icon }}" aria-hidden="true"></i>
<span class="title">{{ item.title }}</span>
<span class="selected"></span>
</a>
</li>
它的工作!感謝您的幫助我先生:)是的,我從API的JSON響應中檢索數據。 – userpr