2016-04-14 15 views
3

Q以下のサービスで以下のインターフェイスモジュールを使用するにはどうすればよいですか?角2:C#で生成されたモデルをインポート/エクスポートする方法

私はC#から生成された次のモデルを持っている場合:

declare module App.Core.Model { 
    interface Address extends App.Core.Model.BaseEntity { 
     addressLine1: string; 
     addressLine2: string; 
     addressLine3: string; 
     area: string; 
     countryCode: string; 
     name: string; 
     postcode: string; 
     town: string; 
    } 
} 

サービス:

ファイルがに住んで
// these don't work, get "model.ts error is not a module" 
    import {Client} from '../interfaces/model'; 
    import {AdminUser} from '../interfaces/model'; 
    import {Building} from '../interfaces/model'; 


    @Injectable() 
    export class AppService { 
     ... 
    } 

  • アプリ/インターフェース/モデル。 ts
  • app/services/service.ts
  • 012あなたは、次の(ドットはアンダースコアに置き換えられている)を行うことができます

答えて

0

declare module App_Core_Model { 
    export interface Address extends App.Core.Model.BaseEntity { 
     addressLine1: string; 
     addressLine2: string; 
     addressLine3: string; 
     area: string; 
     countryCode: string; 
     name: string; 
     postcode: string; 
     town: string; 
    } 
} 
declare module "app_core_model" { 
    export = App_Core_Model; 
} 

"app_core_model" モジュールをインポートするときにその後のインターフェイスは、例えば、利用可能であるべきである:

import {Address} from 'app_core_model'; 

また、インポートを中断してモジュール名にドットを含めることはできません。

+0

ありがとう、私はちょうど生成されたファイルをクリーンアップし、すべてのinterfこれは痛みになっていたので、個別にエースを行った。乾杯。 – Dave