Angularjs Ng-model Bind From Json
I have following dropdown:
Selectize theme
Selected: {{produk.category}}
<ui-select-match >{{$select.selected.name}}</ui-select-match>
From the code you have the value that is selected is produk.category
. Inside there there is only the string "Tours"
. And an string in Javascript has no property called name.
AngularJS normal behavior is to ignore when properties don't exist. So you get nothing. Changing it to this:
<ui-select-match >{{$select.selected}}</ui-select-match>
will solve your problems (since now you are printing the string, not a non-existing property called "name"
in your string).
Solution 2:
Try this
$scope.getProductToEdit = function(id){
Account.getProductToEdit(id)
.then(function(response){
$scope.produk = {}
$scope.produk.category = response.data.product.category;
//console.log($scope.produk); ---> return json
return$scope.produk;
})
.catch(function(response){
})
}
Post a Comment for "Angularjs Ng-model Bind From Json"