您的位置:首页 > Web前端 > AngularJS

angular2 返回一个数组里面的内容禁用 新增一天是可编辑的状态

2017-12-22 00:00 218 查看
摘要: disabled



ts

返回的数组response
this.res_detail_value = res.data.values;//这是返回的数组
// let valueId:any;
let show =1;//这里想表达的意思是如果为1的时候就是返回的值,就表示禁用的状态,如果是其他的值的时候就表示可编辑的状态
for (let resValue of this.res_detail_value) {
this.logger.log(resValue)
this.res_detail_value.valueId = "value" + this.index++;
resValue.show =show;
if(resValue.show == 1){
resValue.show = true;
}else{
resValue.show = false;

}
this.logger.log("*****************")
}
//点击添加的时候增加一条数组在数组里面
private mod_show:any = 2;//我是用2来代替的
private addValueEdit() {
for (let value of this.res_detail_value) {
if (value.value.length == 0) {
swal("请把参数填写完整");
return;
}
}
// this.logger.log(this.param_add_attribute)
let value = {
value: this.param_edit_value,
valueId: "value" + this.index++,
show:this.mod_show++ //这就是判断可编辑的状态
};
this.res_detail_value.push(value)
this.logger.log(this.res_detail_value);
for(let newValue of this.res_detail_value){
if(newValue.show!=1){
newValue.show = false
}
}
}

html

<div class="col-sm-5 form-validate">
<input type="text"    *ngFor="let value of res_detail_value" [disabled]="value.show" style="margin-bottom:10px;"  [(ngModel)]="value.value" class="form-control">
</div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  disabled
相关文章推荐