Ryan Chenkie
Brad McAlister
@ryanchenkie
@sonicparke
Enterprise Corporation, Inc
We miss AngularJS, LLC
Hipster Startup, LLC
Foo Corp
Foo Team #2
Foo Corp Acquisition
Another Foo Corp Aquisition
Bar Corp Acquisition
Bar Corp ???
Bar Corp Legacy App
Old Bar Corp Acquisition
<my-element></my-element>
a.k.a. ISS
Space Station
Space Station
ng add @angular/elements
export class AppModule {
constructor(private injector: Injector) {}
ngDoBootstrap() {
const el = createCustomElement(
TemperatureGaugeComponent,
{ injector: this.injector }
);
customElements.define(
'iss-temperature-gauge',
el
);
}
}
entryComponents: [
TemperatureGaugeComponent
]
[...]
<body>
<iss-temperature-gauge
unit="fahrenheit"
station-component="discombobulator"
></iss-temperature-gauge>
</body>
<app-root>
ng serve
// Used for browsers with partially native support of Custom Elements
import '@webcomponents/custom-elements/src/native-shim';
// Used for browsers without a native support of Custom Elements
import '@webcomponents/custom-elements/custom-elements.min';
npm install @webcomponents/custom-elements
ng add ngx-build-plus
"builder": "ngx-build-plus:build"
--single-bundle --keep-polyfills
"ng build --prod --single-bundle --keep-polyfills"
npm run build
{
"name": "iss-elements",
"version": "0.0.1"
}
npm run npm-pack
npm install <package>
<iss-temperature-gauge
unit="celsius"
station-component="discombobulator"
><iss-temperature-gauge/>
<iss-temperature-gauge (hiTemp)="...">
<iss-temperature-gauge ref={...}>
class App extends Component {
issTempComponent;
handleRef = refNode => {
this.issTempComponent = refNode;
};
render() {...}
}
<iss-temperature-gauge ref={this.handleRef} />
class App extends Component {
componentDidMount() {
this.issTempComponent.addEventListener('hiTemp', e => {
this.setState(...)
});
}
componentWillUnmount() {
this.issTempComponent.removeEventListener('hiTemp');
}
...
render() {...}
}
this.component.addEventListener('hiTemp', e => {
this.setState({
hasHighTemp: e.detail.alert,
name: e.name,
temperature: e.temperature
})
});
ryanchenkie.com
ngauthbook.com
Ryan Chenkie
Brad McAlister
@ryanchenkie
@sonicparke