は私がNgModule-宣言と輸出にインターフェースをエクスポートしようとしたエディタ(Visual Studioのコード)で、すでにこのエラーを取得:ここ[ts] 'MyInterface' only refers to a type, but is being used as a value here.
アングル2モジュールでインターフェイスをエクスポートできませんか?
は、サンプルコード編集-1です:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { MaterialModule } from '@angular/material';
import { MyInterface } from './my.interface';
import { MyService } from './my.service';
@NgModule({
imports: [ CommonModule, FormsModule, MaterialModule.forRoot() ],
declarations: [ MyInterface],//<- this is causing the message
exports: [ MyInterface],
providers: [ MyService ]
})
export class MyModule { }
説明の一部「in the answer to this post:実行時にTypeScriptでインタフェースが消去されるため」 現在、私のアプリを機能モジュールにリファクタリングしているので、今すぐテストすることはできません。インターフェイスを './mypathto/my.interface'からのインポートだけで使用できますか?
コードを投稿してください。インターフェイスのエクスポートとインポートはここでうまくいきます。 –
どこで使いたいですか?プロバイダとして? 「NgModule宣言でインターフェイスをエクスポートしようとしました」とはどういう意味ですか? – yurzui
https://angular.io/docs/ts/latest/guide/dependency-injection.html#!を参照してください。#typescript-interfaces-aren-t-valid-tokens – yurzui