Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用<;筛选IEnumerable;选择>;第二个<;选择>;_Javascript_Html_Angularjs_Dictionary_Ienumerable - Fatal编程技术网

Javascript 如何使用<;筛选IEnumerable;选择>;第二个<;选择>;

Javascript 如何使用<;筛选IEnumerable;选择>;第二个<;选择>;,javascript,html,angularjs,dictionary,ienumerable,Javascript,Html,Angularjs,Dictionary,Ienumerable,在angular脚本中,我通过从ASP.net控制器提供的viewmodel中提取来声明以下内容: $scope.controlleractions = @Html.Raw(Json.JsonCamelCase(Model.ControllerActions)); 产生以下数据: [{"$id":"1", "controller":"Resource", "actions":["Image","File"]}, {"$id":"2", "controller":"Home", "action

在angular脚本中,我通过从ASP.net控制器提供的viewmodel中提取来声明以下内容:

$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"]}]
我希望能够通过一个select元素选择一个控制器,然后使用第二个select元素从actions数组中选择一个动作,但我似乎无法解决这个问题。有人有主意吗

ng模型中的两个输出最好是字符串

这就是我取得的成绩:

<!-- 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>

全部的
{{controlleraction.controller}
全部的
{{action}}

不确定为什么在此处使用
过滤器
,只需将
ng repeat
绑定到
selectedController
即可:

 <option ng-repeat="action in selectedController.actions">{{action}}</option>
{{action}

我试过这个,但不起作用。selectedController是一个字符串,而不是一个包含操作列表的对象。我可以将第一个中的值更改为一个包含列表的对象(controlleraction)但是,ng模型的输出不再是字符串,我更喜欢将其他数据变回我的ASP.net控制器,然后我认为应该使用与实际控制器对应的第三个变量来执行其操作。