angular.js - How to get the text value of select in angular and determine the selected status of option
迷茫2017-05-15 17:00:31
0
4
1034
Provincial and municipal linkages are being carried out. In option, value is the province and city code. Text is the name. How can we determine the selected option and get the text name?
In fact, this is my problem. The solution to the problem is to directly bind the ng-model to the object, and then bind the value of the option to the same object. This solves the 'selection problem'. In the background, the id or text value is taken directly from the object. id or text. thanks!
It is available in the official documentation of angularJS. You need to bring your own ladder The following is an example from the documentation of the version 1.4.7 I used
The result is that the name part is displayed in the option, and the model obtains the id. The model here uses data.repeatSelect because the loop is on the option, resulting in a different scope
Just use ng-options
The code is a bit slow to load. . Wait a moment to see the effect:
http://codepen.io/flybywind/pen/GZyydY
template
script
In fact, this is my problem. The solution to the problem is to directly bind the ng-model to the object, and then bind the value of the option to the same object. This solves the 'selection problem'. In the background, the id or text value is taken directly from the object. id or text. thanks!
It is available in the official documentation of angularJS. You need to bring your own ladder
The following is an example from the documentation of the version 1.4.7 I used
The result is that the name part is displayed in the option, and the model obtains the id. The model here uses data.repeatSelect because the loop is on the option, resulting in a different scope