This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
type Label<T extends object> = { [key in keyof T]: string }; | |
type PartialLabel<T extends object> = { [key in keyof Partial<T>]: string }; | |
interface LoginForm { | |
username: string; | |
password: string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
type Label<T extends object> = { [key in keyof T]: string }; | |
interface LoginForm { | |
username: string; | |
password: string; | |
} | |
@Component({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
interface LoginForm { | |
username: string; | |
password: string; | |
} | |
@Component({ | |
selector: 'app-form', | |
template: ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<app-progressive-image [width]="width" [height]="height" > | |
<img appProgressiveImage [src]="src" /> | |
<div appProgressiveImagePlaceholder>Loading...</div> | |
<div appProgressiveImageFallback>Error!</div> | |
</app-progressive-image> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-progressive-image', | |
template: `<ng-content></ng-content>`, | |
}) | |
export class ProgressiveImageComponent { | |
@Input() height: number; | |
@Input() width: number; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Directive({ | |
selector: 'img[appProgressiveImage]', | |
}) | |
export class ProgressiveImageDirective { | |
@Input() src: string; | |
width: number; | |
height: number; | |
} | |
@Directive({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Directive({ | |
selector: 'img[appProgressiveImage]', | |
}) | |
export class ProgressiveImageDirective { | |
@HostBinding('attr.src') | |
@Input() src: string; | |
@HostBinding('style.width.px') | |
width: number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-progressive-image', | |
template: `<ng-content></ng-content>`, | |
}) | |
export class ProgressiveImageComponent implements AfterContentChecked { | |
@ContentChild(ProgressiveImageDirective) image: ProgressiveImageDirective; | |
@ContentChild(ProgressiveImageFallbackDirective) | |
fallback: ProgressiveImageFallbackDirective; | |
@ContentChild(ProgressiveImagePlaceholderDirective) | |
placeholder: ProgressiveImagePlaceholderDirective; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-progressive-image', | |
template: `<ng-content></ng-content>` | |
}) | |
export class ProgressiveImageComponent implements AfterContentChecked { | |
@ContentChildren(Dimensions) dirs: QueryList<Dimensions>; | |
@HostBinding('style.height.px') | |
@Input() | |
height: number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Dimensions { | |
width: number; | |
height: number; | |
} |