我在AngularJS控制器中加载了动态菜单,我使用ng-repeat在html中显示它,直到这里。
但是在一个案例中(尚未),我不得不在“A”标签的href属性中添加一个url,而是添加一个由ng-click调用的角度方法。
问题是,Angularjs不会渲染此ng-click或它的参数
有一种有角度的方式,输入保存,无代码解决方案吗?
HTML:
// trying to do it injecting ng-click as a tag attribute
<a ng-repeat="menu in mainMenuList" href="{{menu.href}}" {{menu.params}} >{{menu.name}}</a>
// trying to do it injecting function name inside ng-click
<a ng-repeat="menu in mainMenuList" href="{{menu.href}}" ng-click="{{menu.ngclick}}" >{{menu.name}}</a>
JSON:
$scope.mainMenuList = [
// normal link with href and no ngclick nor parameter
{ "name" : "Store" , "href" : "#\/store" },
// trying to do it injecting ng-click as a tag attribute
{ "name" : "Logoff" , "href" : "" , "params" : " ng-click=\"logoff()\" " },
// trying to do it injecting just function name to ngclick attribute
{ "name" : "Test" , "href" : "" , "ngclick" : "userLogoff()" },
];