1

First of all i am new to Angular 2 and i created new project using Angular cli tool.

I have pushed my code here (rather then pasting all files here):

https://github.com/tsingh38/Angular2

When i run ng serve then serve starts successfully but browser shows just "Loading".

As per my research so far, package.json and other files are perfectly fine. In case more info is required then i will answer.

Thanks.

3
  • any errors on the console? Commented Oct 16, 2016 at 10:17
  • press F12 and provide error information from browser Commented Oct 16, 2016 at 12:16
  • angular-cli is good but it comes at second stage. you should go through some basics of angular first Commented Oct 16, 2016 at 13:33

1 Answer 1

1

Go to your src/index.html file and change this:

<app-root>Loading...</app-root>

To this:

<my-app>Loading...</my-app>

Why? Because on your src/app/app.component.ts your selector is my-app:

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

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app works!';
}
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks your solution works but please make me one thing clear, how come angular is going to index.html first, i thought app.component is the first thing in angular and it will look for html defined in app.component ? index.html has priority or what ?
Yes, index.html is the first thing that is rendered by the browser, then after that Angular is boostraped and it starts reading your components html
thanks a lot for clearing my doubt, it makes sense now :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.