View app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { NavMenuComponent } from './nav-menu/nav-menu.component';
import { HomeComponent } from './home/home.component';
import { CounterComponent } from './counter/counter.component';
View package.json
{
"name": "sample",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --extract-css",
"build": "ng build --extract-css",
"build:ssr": "npm run build -- --app=ssr --output-hashing=media",
"test": "ng test",
View gulpfile.js
// preserve folder structure for these files
promises.push(new Promise(function (resolve, reject) {
gulp.src([
'node_modules/@angular/core/bundles/core.umd.min.js',
'node_modules/@angular/common/bundles/common.umd.min.js',
'node_modules/@angular/compiler/bundles/compiler.umd.min.js',
'node_modules/@angular/forms/bundles/forms.umd.min.js',
'node_modules/@angular/router/bundles/router.umd.min.js',
'node_modules/@angular/common/bundles/common-http.umd.min.js',
'node_modules/@angular/platform-browser/bundles/platform-browser.umd.min.js',
View system.js
(function (global) {
System.config({
paths: {
'npm:': './node_modules/',
},
map: {
// maps plain `app` module to `app` package
app: 'build/app',
// angular bundles
View package.json
{
"name": "sample",
"version": "2.0.0-beta.1",
"description": "",
"author": "Rahul Sahay",
"license": "SEE LICENSE IN LICENSE",
"main": "./src/main.js",
"typings": "index.d.ts",
"scripts": {
"ng": "ng",
View angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"sample": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
View package.json
{
"name": "sample",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
View gist:2ba4e4f241d4604c12afd36d78792e82
newRequest() {
const request = new HttpRequest(
"POST", "/api/progress-request", {},
{reportProgress: true});
this.http.request(request)
.subscribe(
event => {
View NgModule.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpClientModule
],
providers: [
[ { provide: HTTP_INTERCEPTORS, useClass:
View gist:3d3d29c92047d8935c368298e81ae902
import {Injectable} from "@angular/core";
import {HttpEvent, HttpHandler, HttpInterceptor}
from "@angular/common/http";
import {HttpRequest} from "@angular/common/http";
import {Observable} from "rxjs/Observable";
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
constructor(private authService: AuthService) {