2017-11-11 6 views
0

この角度コードを実装しようとすると、TypeErrorが発生します。クラス({constructor:function(){}})の周りでエラーを生成します。私はこれ(https://github.com/angular/angular/commit/cac130eff9b9cb608f2308ae40c42c9cd1850c4d)を指摘されていますが、解決策を実装する方法は不明です。どのようにリファクタリングするのですか?amTypeError - Angular^5.0

私はこのコーディング用のものを初めて使っているので、私は代替案を理解するのが大好きです。

これは、レールを使用して最近購入した本の角 とポストグルをまとめたものです。ありがとう。

import "hello_angular/polyfills"; 

import { Component, NgModule } from "@angular/core"; 
import { BrowserModule   } from "@angular/platform-browser"; 
import { FormsModule   } from "@angular/forms"; 
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; 

var CustomerSearchComponent = Component({ 
    selector: "shine-customer-search", 
    template: '\ 
<header> \ 
    <h1 class="h2">Customer Search</h1> \ 
</header> \ 
    ' 
}).Class({ 
    constructor: function() { 
    } 
}); 

var CustomerAppModule = NgModule({ 
    imports:  [ BrowserModule, FormsModule ], 
    declarations: [ CustomerSearchComponent ], 
    bootstrap: [ CustomerSearchComponent ] 
}) 
.Class({ 
    constructor: function() {} 
}); 

答えて

0

私は上記のリンクで情報を理解として、あなたはclassとしてコンポーネントを定義し、@Componentデコレータでそれを飾るために持っています。

@Component({ 
    selector: "shine-customer-search", 
  template: '\ 
<header> \ 
  <h1 class="h2">Customer Search</h1> \ 
</header> \ 
 ' 
}) 
export class CustomerSearchComponent { 
  constructor() { 
    } 
} 

EDIT

ます。また typescriptを使用する必要があります。 javascriptであなたの質問にタグを付けると、これが問題になる可能性があります。

あなたのモジュールは次のようになります。

@NgModule({ 
    imports:  [ BrowserModule, FormsModule ], 
    declarations: [ CustomerSearchComponent ], 
    bootstrap: [ CustomerSearchComponent ] 
}) 
export class CustomerAppModule { } 
+0

を**また、typescriptですを使用する必要が**、いや、それは真実ではありません。) – Alex

関連する問題