2
TypescriptでAngular2で新しいAppを開発しています。すべてのクラスとインタフェースを別々のファイルで宣言し、angular2コンポーネントでクラスとインタフェースを参照するよりクリーンな方法はありますか?別のファイルでtyperscriptクラスを作成し、それをangular2コンポーネントで使用する
import {Component, OnInit, Pipe} from 'node_modules/angular2/core';
import { HTTP_PROVIDERS, Http, Response, Headers } from 'node_modules/angular2/http';
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } from 'node_modules/angular2/router';
import { Observable } from 'node_modules/rxjs/Rx';
@Component({
selector: 'my-App',
templateUrl: '/app/Index.html',
directives: [ROUTER_DIRECTIVES, NewEvent] })
//instead of writing class here , is there any way to declare this class in a
//separate file and injecting it here.
export class Events { }
あなたのすべての輸入:
デコレータとクラスは、他のモジュールからインポートすることができます。あなたは同じことをすることができます。 http://plnkr.co/edit/?p=previewも参照してください。 –