Last active
October 28, 2019 19:45
-
-
Save LayZeeDK/c1ba3fb3a06611487988fd2fdec0be97 to your computer and use it in GitHub Desktop.
Bootstrapping an Angular Ivy component
This file contains 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 { 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'; | |
} | |
} |
This file contains 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 '@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