5
I’m trying to fill in a select with data from my groundwork the problem is that I always have to select the select one time for the data to load. How can I solve this problem?
HTML
<form class="" name="formulario">
<div class="row">
<div class="input-field col s6 m6 l6">
<i class="material-icons prefix">store</i>
<select material-select></select>
<label for="selectCliente">Cliente</label>
</div>
<div class="input-field col s6 m6 l6">
<i class="material-icons prefix">store</i>
<select ng-model="pedido.Hora" material-select></select>
<label for="inputHora">Hora</label>
</div>
</div>
<div class="row">
<div class="input-field col s6 m6 l6">
<i class="material-icons prefix">store</i>
<select ng-model="pedido.ProdutoId"
ng-options="prod.Id as prod.NomeProduto for prod in ListaProdutos" material-select>
</select>
<label for="inputProduto">Produto</label>
</div>
<div class="input-field col s2 m2 l2">
<i class="material-icons prefix">store</i>
<input id="inputQtd" type="number" class="validate" name="Qtd" ng-model="pedido.Qtd" min="0" max="">
<label for="inputQtd">Qua</label>
</div>
<div class="input-field col s2 m2 l2">
<a class="btn-floating btn-large waves-effect waves-light red"><i class="material-icons">add</i></a>
</div>
</div>
</form>
Controller
angular.module("modaFeminina").controller("PedidoController", function ($scope, $http, $base64) {
$scope.pedido = {}
$scope.ListaProdutos = [];
$scope.ListaCliente = [];
$http.get("/Produto/Listar").success(function (produtos) {
$scope.ListaProdutos = produtos;
}).error(function () {
});
});
But keep your watch?
– pmargreff
Watch is an attribute passed in html itself in the select tag
– Al Unser Albuquerque
Legal, had never seen, or paid attention to this way of declaring.
– pmargreff