Angularjs:选择ng模型不工作
我对选择框有问题。当我选择该选项时,我无法获得刚才选择的值。我读了很多答案,但似乎没有一个适合我。这是我的密码 HTML: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" >
<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>