小编psi*_*ros的帖子

如何从 Angular 的库中导出模型?

我创建了一个 Angular 库,但我想导出一个我的应用程序可以使用的模型。我怎样才能做到这一点 ?

例如 :

我的图书馆

库-model.ts

export class LibraryModel{
  //some model data
}
Run Code Online (Sandbox Code Playgroud)

my-library.component.ts

import { Component, OnInit, Input } from '@angular/core';

//some imports    

@Component( {
    selector: '...',
    templateUrl: '...',
    styleUrls: [...]
} )
export class MyLibraryComponent implements OnInit {

    @Input() libInputData: LibraryModel;

    // some other codes
}
Run Code Online (Sandbox Code Playgroud)

my-library.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { MyLibraryComponent} from './my-library.component';
import { LibraryModel} from './library-model';

@NgModule( {
    declarations: [MyLibraryComponent, LibraryModel],
    imports: [ …
Run Code Online (Sandbox Code Playgroud)

angular angular-library

8
推荐指数
1
解决办法
6185
查看次数

标签 统计

angular ×1

angular-library ×1