New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular模板标签<ng-container>、<ng-template> #21
Comments
<div *ngIf="isList;else elseBlock">
<ul>
<li *ngFor="let item of items">
<a routerLink='../detail/{{item.id}}' [queryParams]="{title:item.title}">
{{item.title}}
</a>
</li>
</ul>
</div>
<ng-template #elseBlock>
<div>
分组浏览
</div>
</ng-template> 但是,这样子,比如为true时候,我们生成的code中是会多了个if所谓的标签 <ng-container *ngIf="isList;else elseBlock">
<ul>
<li *ngFor="let item of items">
<a routerLink='../detail/{{item.id}}' [queryParams]="{title:item.title}">
{{item.title}}
</a>
</li>
</ul>
</ng-container>
<ng-template #elseBlock>
<div>
分组浏览
</div>
<div *ngFor="let i of [1,2,3]">
<h3> {{i}}</h3>
</div>
</ng-template> |
注意如上代码如果这样子去写,if块中内容就不会正常显示 <ng-template *ngIf="isList;else elseBlock">
<ul>
<li *ngFor="let item of items">
<a routerLink='../detail/{{item.id}}' [queryParams]="{title:item.title}">
{{item.title}}
</a>
</li>
</ul>
</ng-template>
<ng-template #elseBlock>
<div>
分组浏览
</div>
<div *ngFor="let i of [1,2,3]">
<h3> {{i}}</h3>
</div>
</ng-template> 原因,
|
alanhg
changed the title
angular模板标签<ng-container>、<ng-template>
Angular模板标签<ng-container>、<ng-template>
Dec 7, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: