我現在正在開發網站,並且在ng-repeat
中有編輯註釋字段功能。要編輯註釋字段,用戶需要點擊鏈接先顯示錶單,然後鍵入,然後保存如下。問題是我成功保存後無法隱藏該輸入。編碼如下。如何在angularjs中提交後隱藏表單
index.jade
tr(data-ng-repeat="application in job.applications")
td.notes
div.bold #{getMessage('Notes:')}
div.normal
div(ng-hide='showDetails')
{{application.note}}
.br
a.admin_edit_gray(href='#', ng-click="showDetails = ! showDetails") Edit Note
div(ng-show='showDetails')
textarea.form-control.small-text-font(ng-model='editableTitle', ng-show='showDetails', maxlength="100", ng-trim="false")
div.editable
div(ng-if="editableTitle.length == 100")
| #{getMessage('max 100 symbols.')}
a.small-text-editButton(href='#', ng-click='save(application, editableTitle, application.id)') Save
| |
a.small-text-cancelButton(href='#', ng-click="showDetails = ! showDetails") close
controller.js
$scope.showDetails = false;
$scope.noteFormData = {};
$scope.save = function(application, editableTitle, appId) {
$scope.noteFormData = {
appId: appId,
note: editableTitle
};
mytestService.writeNote($scope.noteFormData).then(
function (notemessage) {
application.note = notemessage;
alert('Note is successfully saved.');
$scope.showDetails = false;
}
);
};
我試圖隱藏形式$scope.showDetails = false;
成功保存後。但它根本不起作用。請幫我解決這個問題。
嘗試在'$ timeout'包裝'$ scope.showDetails = FALSE',可能是消化問題。 –
'writeNote'是否會使用'$ http'使某些AJAX調用將更新發布到您的服務器? – Arkantos
@Arkantos yap,當然。這是異步調用。 – ppshein