Reputation: 1011
My select is the following
<div class="inputCol">
<label>{{'FrequentBeneficiary' | translate}}</label>
<select ng-model="params.beneficiary" ng-options="option.Name as option.Name for option in beneficiaryData"></select>
</div>
</div>
my service call code:
bcsSQLiteStorage.getDataDB(BeneficiariesKey).then(function (data) {
if (data.rows.length > 0) {
console.log("entrou no data.rows.length");
$scope.beneficiariesData = angular.fromJson(data.rows.item(0).value);
$scope.AccountLoaded = true;
MobileLoading.Ionic.hide();
console.log("Beneficiaries Data " + JSON.stringify($scope.beneficiariesData));
$scope.params.beneficiary = $scope.beneficiariesData[0].Name;
console.log($scope.params.beneficiary);
}
and my console.log prints the name just fine
console.log($scope.params.beneficiary);
prints the name correctly, does not print undefined
but my select shows undefined when I am testing it why? something wrong with my select?
Upvotes: 0
Views: 127
Reputation: 220
Define $scope.params.beneficiary=null before calling service means outside of service function block then test once again
Upvotes: 1