Wassim Chegham PRO
Senior Developer Advocate @Microsoft ★ Angular contributor ★ Bazel contributor ★ GDE @Google ★ creator of @itsjustangular / hueaction.dev / ngx.tools / xlayers.dev / angular.run / thundr.dev
ANGULAR
WEB COMPONENTS
INTEROPERABILTY
WILL IT BUILD?
Wassim Chegham
Dev Advocate
@manekinekko
$ ng new my-awesome-app
$ ng build --prod -aot
$ ng test
$ ng lint
$ ng docs
$ ng make-this-awesome
AppModule
CoreModule
FeaturesModule
SharedModule
AppModule
CoreModule
import { NgModule } from '@angular/core';
@NgModule({
imports: [],
declarations: [],
providers: [],
bootstrap: []
})
class AppModule { }
import { Component } from '@angular/core';
@Component({
selector: 'app-foo',
template: 'Hello {{ planet }}'
})
class AppFooComponent {
planet = 'Earth!';
}
<input [value]="firstName">
<pwc-foo [value]="firstName"></pwc-foo>
<div [style.width.px]="mySize">
<label [attr.for]="someName"></label>
<p [ngClass]="{ 'odd': true }"></p>
<button (click)="readRainbow()">
<pwc-foo (bar)="yolo($event)" ></pwc-foo>
<pwc-foo [(title)]="name"></pwc-foo>
<pwc-foo
[title]="name"
(titleChange)="name = $event" >
</pwc-foo>
<section *ngIf="showSection"></section>
<li *ngFor="let item of list"></li>
<pwc-foo [ngSwitch]="switchExpression">
<p *ngSwitchCase="matchExpression">...</p>
<p *ngSwitchDefault>...</p>
</pwc-foo>
<section *ngIf="showSection">
YoLo
</section>
<template [ngIf]="showSection" >
<section>
YoLo
</section>
</template>
you choose
HTML Imports
@Component({ selector:'app-cat' })
class CatComponent { /* ... */ }
@Directive({ selector:'[meow]' })
class MeowDirective { /* ... */ }
<ng-template [ngIf]="showMeow" >
<section>
Meow
</section>
</ng-template>
@Component({
//...
encapsulation: ViewEncapsulation.Emulated
//encapsulation: ViewEncapsulation.Native
//encapsulation: ViewEncapsulation.None
})
class CatComponent { /* ... */ }
import {
NgModule,
CUSTOM_ELEMENTS_SCHEMA
} from '@angular/core';
@NgModule({
declarations: [...],
imports: [...],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
providers: [...],
bootstrap: [...]
})
export class AppModule { }
import { Component } from '@angular/core';
@Component({
selector:'app-cat',
template: `
<wc-cat [name]="catName" (meow)="purr()">
<input name="catName" [(ngModel)]="catName" >
</wc-card>
`
})
class CatComponent { /* ... */ }
import { Component } from '@angular/core';
@Component({
selector:'app-cat',
template: `
<wc-cat [(meow)]="catName"></wc-card>
<wc-cat-poly [meow]="catName"
(meow-change)="catName = $event">
</wc-card-poly>
`
})
class CatComponent { /* ... */ }
YES IT BUILDS
By Wassim Chegham
This talk is all about Angular and Web Component interoperability. See repo for more details: https://github.com/manekinekko/webapp-exercise/tree/angular2
Senior Developer Advocate @Microsoft ★ Angular contributor ★ Bazel contributor ★ GDE @Google ★ creator of @itsjustangular / hueaction.dev / ngx.tools / xlayers.dev / angular.run / thundr.dev