HTML代码如何设置AngularJS值属性
<select class="form-control" id="txtcity" data-ng-model="Register.city" ng-options="item for item in dtcmbCity">
<option value="">Please Select</option>
</select>
<button type="button" ng-click="btnSet();">Set Item</button>
JS代码
$scope.Register = {city: ''};
$scope.dtcmbCity = ['Delhi','Bombay','Chennai'];
$scope.btnSet= function() {
$scope.Register.city = "Delhi"
}
我的问题是,当负载数据(德里,孟买,钦奈)在选择框中显示的形式。然后我点击设置按钮,我想在选择框中设置德里。
感谢,请帮助
与http://stackoverflow.com/questions/37762855/how-to-use-ng-repeat-to-show-all-the-values-coming-from-the-api-in-which-i类似-need/37763050#37763050 –
朋友,您的代码可以正常工作,正如您所描述的那样。看到[这个笨蛋](https://plnkr.co/edit/UwUBg8HdROhH4F5DjHq9) –
什么是确切的问这里?代码似乎在做你正在寻找的东西。 – Deep