0

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?

2
  • 1
    I hope your options contains the beneficiary value which you are setting up as model. Commented Oct 23, 2018 at 11:53
  • Diljohn5741 I am giving the value with $scope.params.beneficiary = $scope.beneficiariesData[0].Name; Commented Oct 23, 2018 at 13:09

1 Answer 1

1

Define $scope.params.beneficiary=null before calling service means outside of service function block then test once again

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.