This file contains 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
<div class="label" #label>Some Label | |
<app-info-button [appInfoPopup]="info" [label]="label"></app-info-button> | |
</div> | |
<ng-template #info> | |
<app-info>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, | |
dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, | |
varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non | |
fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. | |
Pellentesque congue.</app-info> | |
</ng-template> |
This file contains 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: '[myValidator]', | |
providers: [{ | |
provide: NG_VALIDATORS, | |
useExisting: MyValidatorDirective, | |
multi: true, | |
}] | |
}) | |
class MyValidatorDirective implements Validator { | |
validate(control: AbstractControl): ValidationErrors | null { |
This file contains 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, InjectionToken, Inject } from '@angular/core'; | |
export const TOKEN = new InjectionToken<string>('MyToken'); | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'], | |
providers: [ | |
{ provide: TOKEN, useValue: 'my injected object', multi: true }, |
This file contains 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, InjectionToken, Inject } from '@angular/core'; | |
export const TOKEN = new InjectionToken<string>('MyToken'); | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'], | |
providers: [ | |
{ provide: TOKEN, useValue: 'my injected object 1', multi: true }, |
This file contains 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, InjectionToken, Inject } from '@angular/core'; | |
export const TOKEN = new InjectionToken<string>('MyToken'); | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'], | |
providers: [{ provide: TOKEN, useValue: 'my injected object' }] | |
}) |
This file contains 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
<div [ngTemplateOutlet]="defaultTemplate"></div> | |
<ng-template #defaultTemplate> | |
An unexpected error occurred. | |
</ng-template> |
This file contains 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
// not going to work | |
<div class="lesson" *ngIf="array" *ngFor="let element of array"> | |
{{ element }} | |
</div> | |
// working | |
<ng-container *ngIf="array"> | |
<div *ngFor="let element of array"> | |
{{ element }} | |
</div> |
This file contains 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
<div *ngIf="text else defaultTemplate"> | |
{{text}} | |
</div> | |
<ng-template #defaultTemplate> | |
An unexpected error occurred. | |
</ng-template> |
This file contains 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-error-card></app-error-card> | |
<app-error-card [template]="googleItTemplate"></app-error-card> | |
<ng-template #googleItTemplate> | |
Another error text | |
<div> | |
<a href="google.com">Google it</a> | |
</div> | |
</ng-template> |