次のように、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>
助けてくれてありがとう!