0
我是新來的角。我在Angular 4中(點擊)遇到問題。(點擊)不會觸發。試圖尋找解決方案。什麼都沒有解決。以下是我在HTMLAngular 4(點擊)內部不會觸發* ngIf
<div class="col col-12 col-spacing">
<div>
<md-select [placeholder]="result" [(ngModel)]="selectedItemType">
<md-option *ngFor='let attr of result' [value]="attr.fieldType" ng-selected="attr.fieldType"> {{attr.attribute}}
</md-option>
</md-select>
</div>
<div *ngIf="selectedItemType =='string' || selectedItemType =='decimal' || selectedItemType == 'text' || selectedItemType == 'integer'">
<input placeholder="Enter Text" type="text" class="input" [(ngModel)]="txtEntered">
</div>
<div>
<div *ngIf="selectedItemType == 'date'" class="col col-2 col-spacing">
<md-input-container class="datepicker-align">
<input mdInput [mdDatepicker]="startDatepicker" placeholder="Select Date" name="StartDate" id="txtStartDate" [(ngModel)]="date"
#startDate>
<button id="btnOpnStartDate" mdSuffix [mdDatepickerToggle]="startDatepicker"></button>
</md-input-container>
<md-datepicker #startDatepicker></md-datepicker>
</div>
</div>
<div *ngIf="selectedItemType == 'boolean'">
<input type="checkbox" />
</div>
<button *ngIf="selectedItemType" md-raised-button (click)= "Add()" color="accent" >Add</button>
</div>
下面的代碼我的後端/打字稿代碼
class TestClass implements OnInit {
itemSelected: AttrSelectedList;
chkBox: boolean = false;
selectedItemType: string = null;
date: any = null;
test: any;
txtEntered: any;
result: Array<FormatHeader> = [];
constructor() { }
handleOnClose() {
this.dialogRef.close();
}
ngOnInit(): void { here we have logic}
Add() {
this.test = this.txtEntered;
}
}
嗨拉胡爾,感謝您的回覆。對於那個很抱歉。我在類中添加了Add()方法。還是一樣。它沒有解僱 – user2083386
@ user2083386當你把它放回類中時,如果有什麼錯誤,你也可以在'Add()'方法中添加一個控制檯日誌 –
即使在瀏覽器控制檯中,我也沒有收到任何錯誤。 Add()按鈕點擊不會觸發。我的要求是,當我點擊添加按鈕,添加方法需要被解僱,這不是正在發生的 – user2083386