Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Last active October 28, 2019 19:45
Show Gist options
  • Save LayZeeDK/c1ba3fb3a06611487988fd2fdec0be97 to your computer and use it in GitHub Desktop.
Save LayZeeDK/c1ba3fb3a06611487988fd2fdec0be97 to your computer and use it in GitHub Desktop.
Bootstrapping an Angular Ivy component
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'ivy-app',
template: `
<h1>
Hello, {{name}}!
</h1>
`,
})
export class AppComponent implements OnInit {
name: string = 'World';
ngOnInit(): void {
this.name = 'Ivy';
}
}
import '@angular/compiler';
import {
Injector,
Sanitizer,
ɵLifecycleHooksFeature as LifecycleHooksFeature,
ɵrenderComponent as renderComponent,
} from '@angular/core';
import {
DomSanitizer,
ɵDomSanitizerImpl as DomSanitizerImpl,
} from '@angular/platform-browser';
import { AppComponent } from './app.component';
const rootInjector: Injector = Injector.create({
name: 'root',
providers: [
{
deps: [],
provide: DomSanitizer,
useClass: DomSanitizerImpl,
},
{
provide: Sanitizer,
useExisting: DomSanitizer,
},
],
});
renderComponent(AppComponent, {
hostFeatures: [
LifecycleHooksFeature,
],
injector: rootInjector,
sanitizer: rootInjector.get(Sanitizer),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment