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",
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Pwa Demo</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="manifest" href="manifest.json">
View app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ServiceWorkerModule } from '@angular/service-worker';
import { environment } from '../environments/environment';
@NgModule({
declarations: [
AppComponent
View manifest.json
{
"name": "pwa-demo",
"short_name": "pwa-demo",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "/",
"start_url": "/",
"icons": [
{