I have this ng-template. Everything works with the loop. The only problem is that i can't pass the "title" variable with the "let-title".
What's wrong with my syntax? Do I need the asterisk to *ngIf?
"selectPerm(title)" doesn't work. It is always undefined.
<ng-template ngFor
let-perm
let-title="permission.title"
[ngForOf]="permission.data.permissions"
*ngIf="editForm.controls.permissions.controls[permission.data.id].value == '0'">
<tr>
<td></td>
<td>{{perm.name}}</td>
<td><label>Allow: <input type="radio" value="1" formControlName="{{perm.id}}" (click)="selectPerm(title)"></label></td>
<td><label>Deny: <input type="radio" value="-1" formControlName="{{perm.id}}" (click)="selectPerm(title)"></label></td>
<td></td>
</tr>
</ng-template>
Try placing your *ngIf on your "tr" tag and then referencing perm.title instead of a template input variable:
<ng-template ngFor
let-perm
[ngForOf]="permission.data.permissions">
<tr *ngIf="editForm.controls.permissions.controls[permission.data.id].value == '0'">
<td></td>
<td>{{perm.name}}</td>
<td><label>Allow: <input type="radio" value="1" formControlName="{{perm.id}}" (click)="selectPerm(perm.title)"></label></td>
<td><label>Deny: <input type="radio" value="-1" formControlName="{{perm.id}}" (click)="selectPerm(perm.title)"></label></td>
<td></td>
</tr>
</ng-template>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With