Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.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 字符串化选定的ng选项_Javascript_Angularjs - Fatal编程技术网

Javascript 字符串化选定的ng选项

Javascript 字符串化选定的ng选项,javascript,angularjs,Javascript,Angularjs,我有一个选择选项框,它的选项(ng选项)是从$scope内的数组生成的: <select ng-model="formData.method" ng-options="method.name for method in methods | orderBy: 'name'"></select> formData是在服务器端解析的,我遇到的问题是,从select元素中选择的值作为对象而不是字符串传递。例如:method:{name:'Shaken'}, 我对Angula

我有一个选择选项框,它的选项(ng选项)是从$scope内的数组生成的:

<select ng-model="formData.method" ng-options="method.name for method in methods | orderBy: 'name'"></select>

formData是在服务器端解析的,我遇到的问题是,从select元素中选择的值作为对象而不是字符串传递。例如:
method:{name:'Shaken'},

我对Angular很陌生,但我是否错过了一些可以阻止这一切发生的东西?它应该只读取
method:Shaken,

您需要定义为
值作为ArrayFobjects中对象的标签:

ng-options="method.name as method.name for method in methods | orderBy: 'name'"
演示: