短评 · ·

X 归档 2018-10-30

1 条动态 · 图 2 · 视频 0
@yurzui15:08原推文
Remember yourself doing loading in #Angular app?
<div *ngIf="model; else loading">
Model
</div>
<ng-template #loading>
<my-loading></my-loading>
</ng-template>
And this code goes in many components. How to keep it DRY?
Angular structural directive to the the rescue!
还记得在 #Angular 应用里写加载状态的经历吗?
<div *ngIf="model; else loading">
Model
</div>
<ng-template #loading>
<my-loading></my-loading>
</ng-template>
而且这段代码会在很多组件里重复出现。如何保持 DRY?
Angular 结构型指令来救场!
@yurzui 的配图 1/2 @yurzui 的配图 2/2