0

我正在更新 resource.save 回调中的对象,如下所示:

$scope.addProfile = function () {
    User.save( { "id": user_id }, $scope.createdProfile, function( savedUser, getResponseHeaders ) {
        //$scope.$apply(function () {
            $scope.user = savedUser;
            console.debug($scope.user); // I doublechecked that this contains the correct data 
        //});
    });
};

不幸的是,视图没有正确更新。如您所见,我已经尝试将事物包装在应用程序中,这会导致错误“错误:$digest 已在进行中”。因此,我再次评论了这一点。

不更新的视图位如下所示:

<h1>{{user.name}}</h1>
{{user.location}}
...

函数 addProfile 从表单内的按钮调用,如下所示:

<form name='profileForm' >
    <div class="section">
        <label class="title">Name <span class="help">(required)</span>
            <textarea ng-model="createdProfile.name" ></textarea>
        </label>
    </div>
    <div class="section">
        <button class="btn btn-large highlight" ng-disabled="!profileForm.$valid" ng-click="addProfile()">Save</button>
    </div>
</form>

提前感谢您的帮助!

4

1 回答 1

0

您没有在 html 中定义您的控制器。

<ANY ng-controller="{expression}">
...
</ANY>
于 2013-05-13T17:23:28.937 回答