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
// Mocha package.json | |
{ | |
"name": "mocha", | |
... | |
"bin": { | |
"mocha": "./bin/mocha", | |
"_mocha": "./bin/_mocha" | |
}, | |
... | |
} |
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
{ | |
"name": "death-clock", | |
"version": "1.0.0", | |
"scripts": { | |
"start": "node server.js", | |
"test": "mocha --reporter spec test" | |
}, | |
"devDependencies": { | |
"mocha": "^1.17.1" | |
} |
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
export class AppModule { | |
constructor(injector: Injector) { | |
const custom = createCustomElement(HelloWorldComponent,{injector}); | |
customElements.define('app-hello-world', custom); | |
} | |
ngDoBootstrap() {} | |
} |
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
export class AppModule { | |
constructor(injector: Injector) { | |
const custom = createCustomElement(HelloWorldComponent, {injector}); | |
customElements.define('app-hello-world', custom); | |
} | |
} |
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 {NgModule, Injector} from '@angular/core'; | |
import {createCustomeElement} from '@angular/elements'; | |
@NgModule({ | |
declarations: [AppComponent,HelloWorldComponent], | |
imports: [BrowserModule,AppRoutingModule], | |
entryComponents: [HelloWorldComponent], | |
providers: [], | |
bootstrap: [AppComponent] | |
}) |
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
export class EntryAppComponent { | |
showMessage() { | |
const hello = document.getElementById('hello'); | |
hello.innerHTML = '<app-hello-world></app-hello-world>'; | |
} | |
} |
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
<h1>Welcome To Angular Elements</h1> | |
<div id="hello"></div> | |
<button (click)="showMessage()">Display?</button> | |
// entryApp.component.ts | |
export class EntryAppComponent { | |
showMessage() { | |
const hello = document.getElementById('hello'); | |
hello.innerHTML = '<app-hello-world></app-hello-world>'; | |
} |
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
@ViewChild("tpl") tpl: TemplateRef<any>; | |
let view = this.tpl.createEmbeddedView(null); |
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
@Component({ | |
selector: 'sample', | |
... | |
export class SampleComponent{ | |
constructor(private hostElement: ElementRef) { | |
//outputs <sample>...</sample> | |
console.log(this.hostElement.nativeElement.outerHTML); | |
} |
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, AfterViewInit, ViewChild, | |
ViewContainerRef, TemplateRef } from '@angular/core'; | |
@Component({ | |
selector: 'app-example', | |
template: ` | |
<h1>Application Content</h1> | |
<ng-container #container></ng-container> <!-- embed view here --> | |
<h3>End of Application</h3> |