创建一个表单并编辑表单,但不保存(以角度)
create a form and editing the form but not save (in angular )?
嗨,朋友们,我已经创建了一个表单并显示它。如果我点击"编辑按钮",按钮表单将打开并显示我编辑表单并点击"保存"按钮。此按钮无效且不保存数据,请帮助我
代码
// Code goes here
var app = angular.module('theme', []);
app.controller('portfolioController', function($scope) {
$scope.portofoliosBox = [{
title: "Finance Projects",
description: "# of projects Count Sum Aggregate 1"
}, {
title: "Marketing Projects",
description: "# of projects Count Sum Aggregate 2"
}, {
title: "Finance Projects",
description: "# of projects Count Sum Aggregate 3"
}, {
title: "Marketing Projects",
description: "# of projects Count Sum Aggregate 4"
}, {
title: "Finance Projects",
description: "# of projects Count Sum Aggregate 5"
}];
$scope.editFormPortFolio = function(portfolioBox) {
editFormPorfolio = true;
portfolioBox.title = portfolioBox.title;
portfolioBox.description = portfolioBox.description;
}
});
HTML代码
<body ng-app="theme">
<div ng-controller="portfolioController">
<div ng-repeat="portfolioBox in portofoliosBox">
<button ng-click="editFormPorfolio=true" ng-show="!editFormPorfolio">Edit Button</button>
<h5 ng-show="!editFormPorfolio">{{portfolioBox.title}}</h5>
<p ng-show="!editFormPorfolio">{{portfolioBox.description}}</p>
<form ng-show="editFormPorfolio" ng-submit="editFormPortFolio(portfolioBox)">
<label class="edit-pencil">
<button>Save</button>
<input type="submit" ng-show />
</label>
<input type="text" ng-model="portfolioBox.title" />
<textarea row="5" cols="" ng-model="portfolioBox.description"></textarea>
</form>
</div>
</body>
演示
使用portfolioBox 的"编辑"属性
portfolioBox.edit = true
以及保存时
portfolioBox.edit = false
http://plnkr.co/edit/pZSqcTJolkJk7buTGkvf?p=preview
相关文章:
- 我未保存的更改指令需要适用于具有不同名称的所有表单
- html表单,它有文本和表,现在我想在一个简单的文本文件中保存和检索数据,如何实现它
- 将表单输入保存到txt,弹出结果,不更改页面
- 使用记录保存的消息进行表单验证
- 如何停止javascript的执行并允许用户保存表单
- 缺少用于创建的模板.内部服务器错误-聚合物表单保存到数据库
- Chrome扩展表单保存错误
- 如何将动态表单保存到数据库/编辑回表单
- 将图像从表单保存到本地存储并存储/加载它
- CRM 2015 Javascript,防止记录表单保存并关闭
- jQuery 模态表单保存到 JavaScript 数组
- HTML 表单保存临时数据
- 从表单保存和加载数据而不提交
- 使用 jquery/javascript 将数据从 html 表单保存到文本文件
- 使用AngularJS和php将数据从表单保存到数据库
- 将表单保存为json
- 检测主干模型更改以启用表单保存按钮并更新模型
- 将多个表单保存到localStorage
- 将用户输入从web表单保存到文本文件(在云上:URL)并读取相同的内容
- 将表单保存为JSON