2016-07-17 10 views
0

、これは私のapp.js角度2例のエラー

import 'zone.js/lib/browser/zone-microtask'; 
import 'reflect-metadata'; 

import { Component, View, bootstrap } from 'angular2/angular2'; 
import { HelloComponent } from './hello.component'; 

@Component({ 
    selector: 'hello-app' 
}) 
@View({ 
    directives: [HelloComponent], 
    template: ` 
    <div> 
     <hello-component></hello-component> 
    </div> 
    ` 
}) 
class HelloApp { } 

bootstrap(HelloApp, []); 

であり、これは誤りです:

{ [SyntaxError: /code/angular2-example/app.js: Unexpected token (7:0) while parsing file: /code/angular2-example/app.js] pos: 190, loc: Position { line: 7, column: 0 }, _babel: true, codeFrame: '\u001b[0m 5 | \u001b[36mimport\u001b[39m \u001b[32m{\u001b[39m HelloComponent \u001b[32m}\u001b[39m from \u001b[31m\'./hello.component\'\u001b[39m\u001b[1m;\u001b[22m\n 6 | \n> 7 | \u001b[[email protected]\u001b[27mComponent\u001b[34m\u001b[1m(\u001b[22m\u001b[39m\u001b[32m{\u001b[39m\n | ^\n 8 | selector\u001b[1m:\u001b[22m \u001b[31m\'hello-app\'\u001b[39m\n 9 | \u001b[32m}\u001b[39m\u001b[34m\u001b[1m)\u001b[22m\u001b[39m\n 10 | \u001b[[email protected]\u001b[27mView\u001b[34m\u001b[1m(\u001b[22m\u001b[39m\u001b[32m{\u001b[39m\u001b[0m', filename: 'code/angular2-example/app.js',

が、私はしないでくださいそれを見てください。助けてくれますか。私はちょうど角2で始まっています。

+1

にこれ以上のクラス何Angular2のバージョンを使用しているのですか? 'からのインポート、それを@View() 'は数ヶ月前に削除されました。また、' zone-microtask'と 'reflect-metadata'のインポートは何ですか? –

+0

最新の更新リストについてはhttp://stackoverflow.com/a/34697758を参照してください。/5043867 –

答えて

0

あなたのインポートステートメントが間違っています!

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

角度/コア」

import {Component} from '@angular/core'; 
    import (bootstrap) from 'angular2/platform.browser'; 

コンポーネントは、角度/コアから輸入された@」、ビュー角度

+0

インポートの最新リストについては、こちらを参照してください。http://stackoverflow.com/a/346977 58/5043867 –