我现在正在开发网站,并且在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