Below is the code for a dropdown selection:
<h3>Selectize theme</h3>
<p>Selected: {{produk.category}}</p>
<ui-select ng-model="produk.category" theme="selectize" ng-disabled="disabled" style="width: 300px;">
<ui-select-match >{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="cat in categories | filter: $select.search">
<span ng-bind-html="cat.name | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
In my Angular application, I retrieve data in JSON format like this:
$scope.getProductToEdit = function(id){
Account.getProductToEdit(id)
.then(function(response){
$scope.produk = response.data.product;
//console.log($scope.produk); ---> return json
return $scope.produk;
})
.catch(function(response){
})
}
if($stateParams.id){
$scope.getProductToEdit($stateParams.id);
}
I am facing an issue where I cannot assign the JSON data to ng-model="produk.category"
, even though it works for
<p>Selected: {{produk.category}}</p>
The JSON object returns as follows: Object {category: 'Tours'}
Thank you!