angularserve

Angular doesn't render the page when I try start up the server


I've created three components and I've added them to app.module.ts (src/app), inside components there're only selectors, simply because those are my purpose. Angular doesn't render the page when I try start up the server with ng serve.

Versions

Angular CLI: 1.7.3
Node: 8.11.1
OS: linux ia32
Angular: 5.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.3
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0

npm: 5.6.0

When I try start up

ng serve

** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-04-05T12:05:40.204Z                                                          
Hash: b240b8c528ec8570cab0
Time: 25702ms
chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 25.6 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 557 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 41.5 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 7.42 MB [initial] [rendered]

webpack: Compiled successfully.

Solution

  • "Angular doesn't render the page when I try start up the server" / "Only a blank page"

    If you have errors in your code, angular will show a blank page, even if it is compiling.

    So you need to start checking errors in your browser's developer tools, and checking your code.

    Solution: In this case, your problem is in:

    meu-segundo.component.ts, you close a h1 label with h2, change it to:

    <h1>Welcome To Program</h1>

    You can see this errors by typing F12 (Developer Tools) in your browser and checking the console.