How to set a value in select that is set with ng-options

0

My HTML looks like this:

<select ng-model="cliente" ng-options="t.value as t.displayName for t in clientes"></select>

In the Controller of my JS I have:

$scope.clientes // objeto onde tem todos os clientes para alimentar o select
$scope.cliente // esse é o meu ng-model

My select is working perfectly, I can get the data and save it. My question is the following, how do I fill this select via javascript? I thought that when I put up a value in $scope.cliente it would work, but it did not work!

Does anyone know how to do this? Thanks

    
asked by anonymous 23.05.2015 / 01:40

1 answer

1

I continued testing here and found the solution.

In my $ scope.client I was setting a value of type number and must be of type string .

Ex: I changed this:

$scope.cliente = 1;

So:

$scope.cliente = '1';

And it worked!

Hugs

    
23.05.2015 / 01:49