【发布时间】:2017-11-26 19:50:36
【问题描述】:
在我的 Angular 脚本中,我通过从我的 ASP.net 控制器提供的视图模型中提取来声明以下内容:
$scope.controlleractions = @Html.Raw(Json.JsonCamelCase(Model.ControllerActions));
产生以下数据:
[{"$id":"1",
"controller":"Resource",
"actions":["Image","File"]},
{"$id":"2",
"controller":"Home",
"actions":["Index","NotAuthorized"]},
{"$id":"3",
"controller":"Email",
"actions":["Index","Details","Adress"]},
{"$id":"4",
"controller":"Account",
"actions":["Index","Login","Logout","Create"]},
{"$id":"5",
"controller":"Archive",
"actions":["Page1","Page2","Page3","Search"]}]
我希望能够通过一个选择元素选择一个控制器,然后使用第二个选择元素从动作数组中选择一个动作,但我似乎无法解决。有人出主意吗?
ng-models 中的两个输出都最好是字符串
这是我走了多远:
<!-- selecting a controller works fine -->
<select ng-model="selectedController">
<option value="">All</option>
<option ng-repeat="controlleraction in controlleractions">{{controlleraction.controller}}</option>
</select>
<!-- selecting an action from actions that match the selected controller dosn't work -->
<select ng-model="selectedAction">
<option value="">All</option>
<option ng-repeat="action in controlleractions.actions | filter : selectedController">{{action}}</option>
</select>
【问题讨论】:
标签: javascript html angularjs dictionary ienumerable