我已经简化我的code到这一点:
I've simplified my code down to this:
<form ng-submit="doStuff($('select').val())">
<select name="menu">
<option value="foo">bar</option>
</select>
</form>
当我提交表单,我想角传&LT;选择&GT;
的价值是对函数 doStuff()
。最新最好的方式去吗?
When I submit the form, I want angular to pass <select>
's value is to the function doStuff()
. Whats the best way to go about this?
您不需要向下拉的值传递给提交处理。
You dont need to pass the dropdown's value to the submit handler.
这将是作为 $ scope.menu 的doStuff方法中。
It would be available as $scope.menu inside the doStuff method.
此外,你应该使用角的 NG-选项,以填补下拉里面的选项:
Also, you should use angular's ng-options to fill the options inside the dropdown:
<form ng-submit="doStuff()">
<select ng-model="menu" ng-options="item.name for item in items">
</select>
上一篇:Node.js的角度+ =未捕获的ReferenceError:要求没有定义角度、定义、js、Node
下一篇:获取angularJS autcomplete在Webstorm / PHPStormautcomplete、angularJS、PHPStorm、Webstorm