7

for the first time using angular2 , following the instruction from 5 minute Quickstart guide for angular 2.

everything is working good, means no error while run npm start

npm start image

but when i open

localhost:3000

it show Loading... text which is not expecting. according to this example content of index.html should reflects on this.

in console there is error :

EXCEPTION: TypeError: Cannot set property 'endSourceSpan' of null

main.ts

import { bootstrap } from '@angular/platform-browser-dynamic';

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

bootstrap(AppComponent);

app.component.ts

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

@Component({
    selector: 'my-app',
    template: 'My first Angular 2 App</h1>'
})

export class AppComponent {}

index.html

<html>
  <head>
    <title>Angular 2 QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="styles.css">

    <!-- 1. Load libraries -->
     <!-- Polyfill(s) for older browsers -->
    <script src="node_modules/es6-shim/es6-shim.min.js"></script>

    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>

    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
  </head>

  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
  </body>
</html>

Kindly help me what is going wrong.

5
  • 1
    Could you provide the code of your main component? Thanks! Commented May 17, 2016 at 13:13
  • code of main.ts << it's completely taken from the guide Commented May 17, 2016 at 13:15
  • 2
    okay, thanks! And the app.component.ts file? Commented May 17, 2016 at 13:17
  • Maybe this is relevant: stackoverflow.com/a/37070952/1961059 (incorrectly closed tags/typos, too) Commented May 17, 2016 at 13:17
  • 1
    i have added the code in Question. Commented May 17, 2016 at 13:21

2 Answers 2

3

I think that you have a problem in the template of your main component. For example a HTML element that isn't correctly closed:

template : '<div</div>'

See this issue for more details:

Edit

The problem is that your h1 isn't correct (no begin element):

@Component({
  selector: 'my-app',
  template: '<h1>My first Angular 2 App</h1>' // <------
})
export class AppComponent {}
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the quick response. but there is no div in template as you can see
yes.` h1` tag is not opened. Thanks a lot man. Why angular 2 give strange error or I am unable to debug the error correctly.
You're welcome! I think that the Angular team works hard to improve this ;-)
one more query out of this question context. I have installed typings without -g now if I want to make it globally than do I need to remove earlier or any work around for this to make package globally.
0

You should check the port number of nodeserver shows in your terminal, In Angular2 it'll be running in 4200. ie ** NG Live Development Server is running on http://localhost:4200. ** Then open localhost with specified port in browser.

Comments

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.