如何从Angular库(包)中导出类(非组件)

时间:2018-12-27 08:17:43

标签: angular angular6 angular-library

我在这里尝试了几个答案,但没有一个对我有用。 我试图从库中导出Class,并在其他应用程序上使用它。 但是当我尝试执行此操作时,出现此错误:

  

ROR TypeError:   marvilix_header__WEBPACK_IMPORTED_MODULE_1 __。RoutingHeader不是   构造函数

我的代码:routing-class.ts

export class RoutingHeader{

    public itsActive: boolean;
    public Name: string;
    public Button: boolean;
    public Route: string;
    public links: Array<RoutingHeader>;

    constructor(name:string,button:boolean,route:string,links:Array<RoutingHeader>){
        this.Name = name;
        this.Button = button;
        this.Route = route;
        this.links = links;
        this.itsActive = false;
    }

}

public_api.ts

export * from './lib/marvilix-header.service';
export * from './lib/marvilix-header.component';
export * from './lib/marvilix-header.module';
export * from './lib/routing-class';

app.component.ts

import { Component } from '@angular/core';
import { RoutingHeader } from 'marvilix-header';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  public links:Array<RoutingHeader>;
  constructor(){
   this.links = [
     new RoutingHeader("s",false,"s",null)
   ] 
  }
}
有什么想法吗? 提前Tnx!

0 个答案:

没有答案