4

I just ran ng serve -o and only see my index.html file displayed in the angular app I just started modifying. The page just says hello for now:

// index.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Appclient</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root>hello</app-root>
</body>
</html>

The app.component.html has this:

world
<app-header></app-header>
<router-outlet></router-outlet>

The app.component.ts is below:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'startlistsclient';
}

I am not sure what I am missing.

The console error is:

ReferenceError: global is not defined

index.js:43 Webpack 18 ​

cdub
  • 24,555
  • 57
  • 174
  • 303

1 Answers1

0

you need to use @angular/route in app.module.ts

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule, Routes } from '@angular/router';

import { AppComponent } from './app.component';
import { HelloComponent } from './hello.component';

const routes: Routes = [
  { path: 'hello', component: HelloComponent }
];

@NgModule({
  imports:      [ BrowserModule, FormsModule, RouterModule.forRoot(routes) ],
  exports:      [ RouterModule ],
  declarations: [ AppComponent, HelloComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

and <app-header></app-header> this should be defined.

check working demo

Piyush Jain
  • 1,895
  • 3
  • 19
  • 40