- install CLI
npm install -g @angular/cli
- create a new app
ng new sw-demo-app && cd sw-demo-app
- install service worker
npm install @angular/service-worker --save
- enable service worker
ng set apps.0.serviceWorker=true
- build with AoT compilation + optimizations
ng build --aot --prod
This file contains hidden or 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
//hacked up view engine parts | |
import {ComponentFactory, ComponentRef} from './core/linker/component_factory'; | |
import {ErrorHandler} from './core/error_handler'; | |
import {Injector} from './core/di/injector'; | |
import {NgModuleRef} from './core/linker/ng_module_factory'; | |
import {RendererFactory2} from './core/render/api'; | |
import {Sanitizer} from './core/security'; | |
import {initServicesIfNeeded} from './core/view/index'; | |
import {SimpleRendererFactory} from './core/renderer'; |
This file contains hidden or 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, Component} from '@angular/core' | |
import {BrowserModule} from '@angular/platform-browser' | |
@Component({ | |
selector: 'demo-app', | |
template: ` | |
<h1>hello {{name}}</h1> | |
` | |
}) | |
export class DemoApp { |
This file contains hidden or 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
{ | |
"summaries": [ | |
{ | |
"symbol": { | |
"__symbol": 0, | |
"members": [] | |
}, | |
"metadata": { | |
"__symbolic": "class" | |
}, |
This file contains hidden or 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: 'tree', | |
inputs: ['data'], | |
template: ` | |
<span [style.backgroundColor]="bgColor"> {{data.value}} </span> | |
<tree *ngIf='data.left != null' [data]='data.left'></tree> | |
<tree *ngIf='data.right != null' [data]='data.right'></tree> | |
` | |
}) | |
export class TreeComponent { |
This file has been truncated, but you can view the full file.
This file contains hidden or 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
/* | |
AngularJS v1.5.11-local+sha.f73a65146 | |
(c) 2010-2017 Google, Inc. http://angularjs.org | |
License: MIT | |
*/ | |
(function(H) { | |
'use strict'; | |
function N(a) { | |
return function() { |
This file contains hidden or 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 {mock, module} from 'angular'; | |
import {NG1_MODULE, NG1Service} from './ng1.service'; | |
// One option is to mock out the downgraded services when testing in AngularJS | |
const mockModule = module('mockNg2Module', []) | |
.service('ng2service', class MockNg2Service { | |
getMessage() { return 'Always look on the bright side of life.'; } | |
}); |
test foo bar
<foo>
```md
foobar
This file contains hidden or 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
const NgCompilerPlugin = require('@ngtools/webpack'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin') | |
const webpack = require('webpack'); | |
const path = require('path'); | |
module.exports = { | |
entry: { | |
'admin-app': './src/admin/main.ts', | |
}, | |
resolve: { | |
extensions: ['.ts', '.js'], |
This file contains hidden or 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 {Observable} from 'rxjs' //the entire package, 300+KB | |
import {Observable} from 'rxjs/Observable' //just Observable, no operators, ~8KB | |
import {Subject} from 'rxjs/Subject' //just Subject, no operators | |
import 'rxjs/add/operator/map' //patch Observable proto with map operator |