美文网首页程序员
angularjs 双向绑定失效

angularjs 双向绑定失效

作者: 憨厚老实的老赵 | 来源:发表于2018-06-06 18:25 被阅读0次
$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 双向绑定失效

    本文链接:https://www.haomeiwen.com/subject/rekisftx.html