Senior Frontend Developer @
Creator of DevNote
Credit: Ivy A deep dive into the heart of Angular by Martina Kraus https://t.co/Z1M3TIWzL4?amp=1
Credit: Ivy Renderer for Dummies by Gerard Sans https://slides.com/gerardsans/components-conf-ivy-renderer#/
<div class="greeting">
Hello, world!
</div>
Credit: The Post-Ivy World by Minko Gechev https://t.co/XOT3n8rQYd?amp=1
Credit: The Post-Ivy World by Minko Gechev https://t.co/XOT3n8rQYd?amp=1
Credit: Angular's Future with Ivy by Manfred Steyer https://speakerdeck.com/manfredsteyer/angulars-future-with-ivy
Credit: Angular Connect Day 1 Keynote https://g.co/ng/ac2019
Credit: Suguru Inatomi Twitter https://twitter.com/laco2net/status/1193726958284111874
Credit: Suguru Inatomi Twitter https://twitter.com/laco2net/status/1193730598319210496
Angular 8.3
Angular 9.0 RC4
// tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
...
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictTemplates": true
}
}
Basic Mode
Full Mode
Strict Mode
interface User {
name: string;
address: {
city: string;
state: string;
}
}
<div *ngFor="let user of users">
<h2>{{config.title}}</h2>
<span>City: {{user.address.city}}</span>
</div>
Credit: The Post-Ivy World by Minko Gechev https://t.co/XOT3n8rQYd?amp=1
Credit: The Post-Ivy World by Minko Gechev https://t.co/XOT3n8rQYd?amp=1
Credit: The Post-Ivy World by Minko Gechev https://t.co/XOT3n8rQYd?amp=1
Credit: The Post-Ivy World by Minko Gechev https://t.co/XOT3n8rQYd?amp=1
Opting out of Ivy
// tsconfig.app.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [ ...],
"include": [
"src/**/*.d.ts"
],
"angularCompilerOptions": {
"enableIvy": false
}
}
Ivy Compatible Guide
<button cdkCopyToClipboard="👋 You copied me!">Click to copy</button>
constructor(private clipboard: Clipboard) {}
copyId(id: string) {
this.clipboard.copy(id)
}
<google-map
height="500px"
width="100%"
[zoom]="zoom"
[center]="center"
[options]="options"
(mapClick)="click($event)"
>
<map-marker
#markerElem
*ngFor="let marker of markers"
[position]="marker.position"
[label]="marker.label"
[title]="marker.title"
[options]="marker.options"
(mapClick)="openInfo(markerElem, marker.info)"
>
</map-marker>
<map-info-window>{{ infoContent }}</map-info-window>
</google-map>
@ViewChild(ChildDirective) child: ChildDirective;
@ViewChild(ChildDirective, { static: false }) child: ChildDirective; // similar to above code
Replace TestBed.get with TestBed.inject
TestBed.get(ChangeDetectorRef) // returns any
TestBed.inject(ChangeDetectorRef) // returns ChangeDetectorRef
No more entryComponents
@NgModule({
imports: [MatDialogModule],
declarations: [AppComponent, ExampleDialogComponent],
entryComponents: [ExampleDialogComponent],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
*with experimental API
Credit: Angular's Future with Ivy by Manfred Steyer https://speakerdeck.com/manfredsteyer/angulars-future-with-ivy
const routes: Routes = [
{
path: 'comic/:comicId',
component: withRoute(ComicComponent)
}
];
import {Component, Input, ɵrenderComponent as renderComponent, Pipe, ɵmarkDirty as markDirty} from '@angular/core';
import '@angular/compiler';
@Component({...})
class ChildComponent { ... }
@Pipe({ name: 'capitalize' })
class CapitalizePipe { ... }
@Component({
selector: 'app-cmp',
template: '<zippy title="Toggle">{{ label | capitalize }}</zippy>',
deps: [ChildComponent, CapitalizePipe]
})
class AppComponent {
label = 'hello world';
}
renderComponent(AppComponent);
Credit: angular-ivy-demo by Minko Gechev https://github.com/mgechev/angular-ivy-demo
import {Component, Input, ɵrenderComponent as renderComponent, Pipe, ɵmarkDirty as markDirty} from '@angular/core';
import '@angular/compiler';
@Component({
selector: 'zippy',
template: `
<button (click)="toggle()">
{{title}}
</button>
<div [hidden]="!show">
<ng-content></ng-content>
</div>
`,
})
class ChildComponent {
@Input() title: string;
show = false;
toggle() {
this.show = !this.show;
markDirty(this);
}
}
...
Credit: angular-ivy-demo by Minko Gechev https://github.com/mgechev/angular-ivy-demo