0
Inputs of type select are not selected when loading a form from an object. The values of select are set in the controller. How do I load the page and select them with the object values?
For example, if the project type value is 2, select comes with the option with value 2.
HTML:
<select class="form-control" name="tipo" ng-model="vm.projeto.tipo" ng-options="k as v for (k, v) in vm.tipos">
<option value="">Selecione o tipo projeto</option>
</select>
Ctrl:
vm.projeto = {
nome: "Projeto 1",
tipo: 2
};
vm.tipos = {
1: "Tipo 1",
2: "Tipo 2",
3: "Tipo 3"
};
EDIT: In this post: How to set a value in select that is mounted with ng-options, the solution was to use a string type value instead of number, but I did the test and it did not work, the curious thing is that so it seems to change the option and back to the default very fast.