Instantly share code, notes, and snippets.

View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Poseidon</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
View angular.json
module.exports = {
"externals": {
"rxjs": "rxjs",
"@angular/core": "ng.core",
"@angular/common": "ng.common",
"@angular/platform-browser": "ng.platformBrowser",
"@angular/elements": "ng.elements"
}
}
View header-module.ts
import { NgModule, Injector } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule, provideRoutes } from '@angular/router';
import { HttpModule } from '@angular/http';
import { HeaderComponent } from './header.component';
import { createCustomElement } from '@angular/elements';
@NgModule({
imports: [
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Angular Elements Demo</title>
</head>
<body>
View build-script.js
const fs = require('fs-extra');
const concat = require('concat');
(async function build() {
const files = [
'./dist/ng-elements/runtime.js',
'./dist/ng-elements/polyfills.js',
'./dist/ng-elements/main.js'
]
View app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Injector } from '@angular/core';
import { createCustomElement } from '@angular/elements';
import { GreeterComponent } from './greeter/greeter.component';
@NgModule({
declarations: [
GreeterComponent
],
imports: [
View greeter.ts
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-greeter',
templateUrl: './greeter.component.html',
styleUrls: ['./greeter.component.css'],
encapsulation: ViewEncapsulation.Native
})
export class GreeterComponent implements OnInit {
View app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Injector } from '@angular/core';
import { GreetComponent } from './greet/greet.component';
import { createCustomElement } from '@angular/elements';
@NgModule({
declarations: [
GreetComponent
],
imports: [
View greet.component.ts
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-greet',
template: `
<h2>
Welcome to Angular Elements demo!
</h2>
`,
styles: [],
View ngsw.json
{
"configVersion": 1,
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"updateMode": "prefetch",
"urls": [
"/favicon.ico",