2017-09-25 1 views
1

私はアンギュラ2を初めて使用しています。設定を行うにはすべての要件を満たしていますが、まだエラーが発生しています。 これは、私はすでに私のルートフォルダにNode.jsのクイックスタートのファイルをインストールしていますが、すでにpackages.jsonからパッケージを復元し、私のコンポーネントビジュアルスタジオでアンギュラ2を設定する

import { Component } from "@angular/core" 

@Component({ 

    selector = 'my-app', 
    template = `<h1> Hello {{name}} </h1>` 
}) 

export class AppComponent { 

    name: string = "First Project"; 
} 

です。あなたが選択

  • TS2304をもしかして名「セレクタ」を見つけることができません - - 名前を見つけることができません「テンプレート
  • これはされて私は私のプロジェクト

    • TS2552を構築していたとき、私は、このエラーが発生しています私app.module.ts

      import { NgModule }  from '@angular/core'; 
      import { BrowserModule } from '@angular/platform-browser'; 
      
      import { AppComponent } from './app.component'; 
      
      @NgModule({ 
          imports:  [ BrowserModule ], 
          declarations: [ AppComponent ], 
          bootstrap: [ AppComponent ] 
      }) 
      export class AppModule { } 
      

      は、これが私のtsconfig.jsonある

      { 
          "compileOnSave": true, 
          "compilerOptions": { 
          "target": "es5", 
          "module": "commonjs", 
          "moduleResolution": "node", 
          "sourceMap": true, 
          "emitDecoratorMetadata": true, 
          "experimentalDecorators": true, 
          "lib": [ "es2015", "dom" ], 
          "noImplicitAny": true, 
          "suppressImplicitAnyIndexErrors": true, 
          "typeRoots": [ "../node_modules/@types" ] 
          } 
      } 
      

    答えて

    1

    削除 '=' と追加 ':'、それはオブジェクトだから:あなたが完了している場合

    @Component({ 
    
        selector : 'my-app', 
        template : `<h1> Hello {{name}} </h1>` 
    }) 
    
    +1

    感謝:) #peace – faizan

    +1

    、答えを受け入れてください:) –

    関連する問題