【发布时间】:2018-10-23 11:31:20
【问题描述】:
我的选择如下
<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
但我在测试时选择显示未定义 为什么?我的选择有问题吗?
【问题讨论】:
-
我希望您的选项包含您设置为模型的受益人价值。
-
Diljohn5741 我用 $scope.params.beneficiary = $scope.beneficiariesData[0].Name; 给出值;
标签: javascript html angularjs