棱角分明的隐藏形式
angular - hiding form
本文关键字:隐藏 更新时间:2023-09-26
我有一个<h4>
,它有一个项目标题,如果你点击标题,它就会变成一个带有提交和取消按钮的文本框。我已经完成了所有这些工作,我的问题是试图在ajax reguest之后隐藏表单
html:
<div class="col-xs-12" ng-show="editThis">
<div class="col-xs-8">
<input type="text" class="form-control" ng-model="topic.TopicName" />
</div>
<div class="col-xs-2 pull-right">
<input type="button" class="btn-xs btn-success btn" ng-click="editDetails(topic)" value="submit" />
</div>
<div class="col-xs-2 pull-right">
<input type="button" class="btn btn-xs btn-danger" value="cancel" ng-click="editThis = false" />
</div>
请参阅我使用$scope.editThis
来确定显示或的天气
我不知道为什么这不起作用。
$http.post("/MyVault/EditTopic", { topicEditId: item.VaultTopicId, topicEditName: item.TopicName, topicEditDescription: item.TopicDescription })
.then(function(data, status, headers, confis) {
$scope.editThis = false; // never gets reflected in view
});
请在此处查看演示http://jsbin.com/saduju/4/edit
JS:
var app = angular.module('app', []);
app.controller('firstCtrl', function ($scope, $http) {
$scope.topics = [
{TopicName: "First Topic" },
{TopicName: "Second Topic"},
{TopicName: "Third Topic"}
];
$scope.editDetails = function (topic) {
$http.post("/MyVault/EditTopic", {
topicEditName: topic.TopicName
})
//success calback
.then(function (data, status, headers, confis) {
})
//error calback
.then(function (error) {
})
//finally calback
.then(function () {
//--change editThis to topic.editThis
topic.editThis = false;
});
};
});
html:
<body ng-app="app">
<div ng-controller="firstCtrl">
<div ng-repeat="topic in topics" >
<!--change topic to topic.editThis-->
<h4 ng-click="topic.editThis=true">{{topic.TopicName}}</h4>
<!--change topic to topic.editThis-->
<div class="col-xs-12" ng-show="topic.editThis">
<div class="col-xs-8">
<input type="text" class="form-control" ng-model="topic.TopicName" />
</div>
<div class="col-xs-2 pull-right">
<input type="button" class="btn-xs btn-success btn" ng-click="editDetails(topic)" value="submit" />
</div>
<div class="col-xs-2 pull-right">
<input type="button" class="btn btn-xs btn-danger" value="cancel" ng-click="editThis = false" />
</div>
</div>
</div>
</body>
相关文章:
- 在单击任何位置时隐藏元素,而不检查每次DOM单击
- 显示5秒后隐藏潜水
- 在不使用JQuery的情况下隐藏DOM中的选定元素
- 剑道UI内联编辑:如何在点击其他按钮时隐藏按钮
- 浮动页脚栏-使用Bootstrap隐藏
- 在jquery中为显示/隐藏设置cookie
- 单击按钮后如何逐个调用分区,上一个分区将隐藏
- 从var向代码隐藏函数传递值
- Image赢得't隐藏在滚动jQuery上
- 具有rowGrouping的数据表无法隐藏列
- Jquery隐藏未触发
- JavaScript 检查隐藏字段中的值并将其设置为隐藏字段值
- 分部隐藏在jquery中不起作用
- 点击后隐藏潜水?(但如果Div是一面旗帜呢?)
- javascript.点击隐藏事件故障
- 禁用(而不是隐藏)浏览器滚动条
- PHP Javascript显示/隐藏按钮不工作
- 在mvc应用程序中,在回发时保留最初隐藏的文本框的隐藏或可见状态
- 如何通过溢出来判断元素被切断了多少像素:隐藏在父级上
- ng隐藏和ng显示无法正常工作