我的选择如下
<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>
我的服务呼叫代码:
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);
}
然后我的console.log会很好地打印出名称
console.log($scope.params.beneficiary);
prints the name correctly, does not print undefined
但是我的选择在测试时显示未定义 为什么?我的选择有问题吗?
答案 0 :(得分:0)
在调用service表示超出服务功能块之前,先定义$ scope.params.beneficiary = null,然后再次测试