angularjs 双向绑定失效

$scope.getBankAccount = function () {
    $http.get('/sys/orgs/' + $scope.org.org_id + '/bank_account').then(function (resp) {
        $scope.bankaccount = resp.data;
        $scope.bankCtrl.edit = false;
    });
 };

$scope.saveBankAccount = function () {
    $http.put('/sys/orgs/' + $scope.org.org_id + '/bank_account', $scope.bankaccount).then(function () {
          $scope.getBankAccount();
    }, function (resp) {
          commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
    })
 };

一开始请求getBankAccount 返回值是空的情况下导致$scope.bankaccount也为空,而正确的空返回值应该是{},当$scope.bankaccount={}时,html页面的ng-model="bankaccount.*"才能解析成json字符串放入$scope.bankaccount

你可能感兴趣的:(angularjs 双向绑定失效)