【发布时间】:2017-11-01 15:58:06
【问题描述】:
这是我的 html 代码...
<li class="col-xs-12" style="padding-top: 15px;" *ngFor="let pro of product">
<div class="row">
<img src="{{pro.ImageUrl}}" class="img-responsive col-xs-4" />
<div class="col-xs-5">
<a class="cartTxt">{{pro.Name}}</a><br />
<label style="color: #ea4748; font-weight: 100; font-size: 15px;">Rs {{pro.Price}}</label><br />
<h6 style="color: grey; font-size: 12px;">
<span *ngIf="!editClick">Qty : {{pro.Quantity}}</span>
<span *ngIf="editClick"><input type="text" value="{{pro.Quantity}}" /></span>
<br />
<br />
Size :{{pro.Size}}
</h6>
</div>
<div class="col-xs-3">
<a *ngIf="editClick" (click)="update()">Update</a>
<a *ngIf="editClick" (click)="cancel()">Cancel</a>
<button type="button" (click)="edit()" *ngIf="!editClick" style="background-color:transparent;border:none;"><img src="images/edit.svg" class="img-responsive pull-left" style="height: 15px; width: 15px;" /></button>
<img src="images/cross.svg" *ngIf="!editClick" class="img-responsive pull-right" style="height: 15px; width: 15px;" />
</div>
</div>
<!--<div class="clearfix"></div>-->
</li>
这是我的组件代码...
ngOnInit(): void {
this.isUsername = sessionStorage.getItem('username');
if (this.isUsername != null) {
this.signin = true;
this.userN = sessionStorage.getItem('username');
this.loadCart();
}
}
loadCart() {
this._loginService.cart().subscribe(res => this.product = res);
}
edit() {
alert("");
this.editClick = true;
}
在编辑时单击所有项目而不是一个特定项目是可编辑的。 我看到了其他解决方案,但它对我不起作用
【问题讨论】:
标签: angular edit angular2-template angular2-forms