Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.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
Angularjs:选择ng模型不工作_Angularjs - Fatal编程技术网

Angularjs:选择ng模型不工作

Angularjs:选择ng模型不工作,angularjs,Angularjs,我对选择框有问题。当我选择该选项时,我无法获得刚才选择的值。我读了很多答案,但似乎没有一个适合我。这是我的密码 HTML: <select class="wide" style="width: 96%;height: 100px;" ng-options="element as element.type for element in elements" ng-model="selectedType" >

我对选择框有问题。当我选择该选项时,我无法获得刚才选择的值。我读了很多答案,但似乎没有一个适合我。这是我的密码

HTML:

<select class="wide" style="width: 96%;height: 100px;" 
    ng-options="element as element.type for element in elements"
    ng-model="selectedType" >                                                                                             
    <option value="">Choose an option</option> 
</select>
<p> {{selectedType}} </p>
{{selectedType}

不显示任何内容


提前感谢

需要在控制器范围内设置元素
。e、 g

另外,将控制器连接到视图。e、 g


选择一个选项
{{selectedType}}


请参阅需要在控制器范围内设置的

元素。e、 g

另外,将控制器连接到视图。e、 g


选择一个选项
{{selectedType}}


查看

作为
仅显示值,但对于ng型号,显示整个选定项目

因此,您需要wirte:

 <p> {{selectedType.type}} </p>
{{selectedType.type}


作为的
仅用于显示值,但对于ng型号,则显示整个选定项目

因此,您需要wirte:

 <p> {{selectedType.type}} </p>
{{selectedType.type}

<body ng-controller="ExCtrl">
  <select class="wide"
    ng-options="element.type for element in elements"
    ng-model="selectedType" >                                                                                             
    <option value="">Choose an option</option> 
  </select>
  <p>{{selectedType}} </p>
</body>
 <p> {{selectedType.type}} </p>