我構建了一個應用程序,顯示消息時,當用戶按下edit
我想用它的值初始化消息textarea
我創建了一個名爲notification
的工廠以從我的數據中獲取消息基地和控制器我稱這種工廠:Angular:如何使用默認值初始化textarea
$scope.notification = notification.getNotification($stateParams.id);
$scope.notification.then(
function(notification) {
$scope.notification = notification;
console.log($scope.notification.message);
},
function(response) {
console.log('error fetching the notification', response);
}
);
和HTML:
<textarea ng-model="item.message" class="form-control" ng-init="item.message={{notification.message}}"></textarea>
textarea的保持爲空,這就是我在我的元素檢查了:
<textarea ng-model="item.message" class="form-control ng-pristine ng-untouched ng-valid" ng-init="item.message=hello"></textarea>
'' – YOU