欢迎各位兄弟 发布技术文章
这里的技术是共享的
As mentioned in the previous comment <ng-container *ngIf="first; else notFirst">
Hello World!
</ng-container>
<ng-template #notFirst>
Or Not!
</ng-template> |
Right. Thanks, I was little bit confused, because lately I've been working with Aurelia and there it works little bit differently. (There everything works with Btw I just noticed it is required to use It would be perfect if this could be used: <ng-container *ngIf="first; else notFirst">
Hello World!
</ng-container>
<ng-container #notFirst>
Or Not!
</ng-container> |
It's OK to use <ng-template [ngIf]="first" [ngIfElse]="notFirst">
Hello World!
</ng-template>
<ng-template #notFirst>
Or Not!
</ng-template> |
@trotyl Thanks! I haven't seen that in documentation :( |
@klinki there is an explanation of desugaring of |
@tytskyi Thanks. I was looking at https://angular.io/docs/ts/latest/api/common/index/NgIf-directive.html#!#ngIfElse-anchor and unfortunately there is no example with destructured syntax for if-else :( |
@klinki sorry, but there is that example on the page:
Syntax <div *ngIf="condition">...</div>
<div template="ngIf condition">...</div>
<ng-template [ngIf]="condition"><div>...</div></ng-template> |
@tytskyi Not for |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
klinki commented on 30 May 2017
I'm submitting a ... (check one with "x")
Current behavior
<ng-template *ngIf="something; else somethingElse">this is true</ng-template>
doesn't work properly - only else branch is showed.Expected behavior
It should work in both cases.
Minimal reproduction of the problem with instructions
http://plnkr.co/edit/ezqIoOmJ03sRCYG4kvkB?p=preview
Try to click on first toggle button
Angular version: 4.1.3