2

Hey In my angular2 app I m gettign this error :

Potentially unhandled rejection [3] Error loading "app" at     http://localhost:8080/app.js

I m using official example, here is code :

app.js

 import {Component, View, bootstrap} from 'angular2';
 @Component({
   selector: 'my-app'
 })
 @View({
   template: '<h1>My first Angular 2 App</h1>'
 })
 class AppComponent {
 }
 bootstrap(AppComponent);

index.html

 <!DOCTYPE html>
 <html>
   <head>
     <script src="https://github.jspm.io/jmcriffey/[email protected]/traceur-runtime.js"></script>
     <script src="https://jspm.io/[email protected]"></script>
     <script src="https://code.angularjs.org/2.0.0-alpha.26/angular2.dev.js">     </script>
   </head>
   <body>
     <my-app></my-app>
     <script>
       System.import('app');
     </script>
   </body>
 </html>
1
  • in app.js change first line to from 'angular2/angular2' Commented Sep 14, 2015 at 11:23

3 Answers 3

2

Try:

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

Comments

1

You are not using correct import statement.

Replace import {Component, View, bootstrap} from angular2 with

   import {Component, View} from 'angular2/core';
   import {bootstrap} from 'angular2/platform/browser'

Check the official Angular2 quick cheat sheet reference here:

Comments

0

As of [email protected] the namespacing on imports has changed.

import {Component, View} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';

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

bootstrap(AppComponent);

If you're still using an alpha version the import should be

import {Component, View, bootstrap} from 'angular2/angular2';

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.