2017-02-17 5 views
2

カスタムコンポーネントを作成する際に、以下のエラーが発生します。シンボル値を静的に解決する際にエラーが発生しました。関数 'CreateCustomComponent'を呼び出すと、関数呼び出しはサポートされません。

シンボル値を静的に解決する際にエラーが発生しました。関数 'CreateCustomComponent'を呼び出すと、関数呼び出しはサポートされません d。関数またはラムダを、エクスポートされた関数への参照で置き換えて、シンボルcus_inputを解決することを検討してください。

マイファイルは以下のようになります。いずれか私のコードの下に私に答えを与えてください?

動的コンポーネントを作成mは私はmが動的コンポーネントを作成し、これらのコンポーネントの入力を使用するためのjQueryプラグインを設定している意味し、なぜ「app.modeule.ts」に以下のように同様に

ここ
import { MY_INP_Component} from './customcomponent/core'; 

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


@NgModule({ 
    imports: [BrowserModule, FormsModule, HttpModule,  RouterModule.forRoot(rootRouterConfig, { useHash: true })], 
    declarations: [AppComponent, 
    MY_INP_Component 
    ], 
    bootstrap: [AppComponent], 

    }) 
export class AppModule { } 

インポート

export class MyComponent { 

constructor() { 
    console.log("Component created"); 
} 
} 
export function CreateCustomComponent(componentArgs: { 
selector: string, 
inputs: Array<string>, 
template: string 

}): Type<any> { 

let comp = Component(componentArgs); 
return comp.Class({ 
    extends: MyComponent, 
    constructor: [] 
}); 
} 

export let cus_input :any = CreateCustomComponent({selector: 'cus-inp',inputs : ["myinput"],template : '<input [value]="myinput" />'}) 

export const MY_INP_Component: any = [cus_input]; 

jqueryプラグインで出力します。

答えて

3

CLIバージョンのアップグレード後もこの問題が発生しました。それはAOTコンパイラと関係があります。

あなたはエクスポートとラップあなたの関数を別の関数でアプリのモジュールで(アプリモジュールでなければならない)、その後、そのようにエクスポートされた関数を使用することで、この問題を解決することができます

export function doCreateCustomComponent(){ 
    return CreateCustomComponent(...); 
} 

@NgModule({ ... 
declarations: [doCreateCustomComponent], 
bootstrap: [doCreateCustomComponent] 
... }) 
export class AppModule { } 

(私はあなたを簡素化しましたコード少し)

+0

ありがとうございます。この解決策は私の問題を解決するのに役立ちます –

+0

...また、私にとってはうまくいかないようです – Tyguy7

関連する問題