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
class Person { | |
@storage() public name: string; | |
@storage('sur', 'session') public surname: string; | |
constructor(name : string, surname : string) { | |
this.name = name; | |
this.surname = surname; | |
} |
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 { Directive, Input } from '@angular/core'; | |
import { TemplateRef, ViewContainerRef } from '@angular/core'; | |
import { select } from "ng2-redux"; | |
import { Observable } from "rxjs"; | |
@Directive({selector: '[showIfLoggedIn]'}) | |
export class ShowIfLoggedInDirective { | |
subscription; | |
@Input('showIfLoggedIn') renderTemplate; |
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
<p *ngIf="condition"> | |
Hello, world! | |
</p> | |
That turns into this: | |
<template [ngIf]="condition"> | |
<p> | |
Hello, world! | |
</p> | |
</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
<monster-details *showIfLoggedIn="true"></monster-details> | |
<nav> | |
<ul> | |
<li *showIfLoggedIn="false">Sign in</li> | |
<li *showIfLoggedIn="false">Sign up</li> | |
<li *showIfLoggedIn="true">Log out</li> | |
</ul> | |
</nav> |
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 { Directive, forwardRef } from "@angular/core"; | |
import { NG_ASYNC_VALIDATORS, Validator, AbstractControl } from "@angular/forms"; | |
import { Observable } from "rxjs"; | |
@Directive({ | |
selector: "[asyncValidator][formControlName], [asyncValidator][ngModel]", | |
providers: [ | |
{ | |
provide: NG_ASYNC_VALIDATORS, | |
useExisting: forwardRef(() => AsyncValidator), multi: true | |
} |
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
export default class AsyncValidator implements Validator { | |
} |
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
validate( c : AbstractControl ) : Promise<{[key : string] : any}>|Observable<{[key : string] : any}> { | |
} |
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
validateUniqueEmailPromise( email : string ) { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
if( email === "[email protected]" ) { | |
resolve({ | |
asyncInvalid: true | |
}) | |
} else { | |
resolve(null); | |
} |
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
validate( c : AbstractControl ) { | |
return this.validateUniqueEmailPromise(c.value); | |
} |