代码之家  ›  专栏  ›  技术社区  ›  RoboBear

Angular 6导入功能模块失败-修饰符中不支持函数调用

  •  0
  • RoboBear  · 技术社区  · 6 年前

    我是AngularJS 6的新手,以前在AngularJS 1.x工作过。我目前正试图导入一个自定义模块到我的主应用程序,并有一个错误,我认为我误解了。我看到过其他一些与此相关的SO帖子,我认为这是AOT在Angular中编译的某种问题,但我不确定如何修复它。

    基本上,我在同一个“根”目录中有两个模块。其中一个模块——www——是我的“主应用程序”。另一个服务是处理服务数据的自定义应用程序。我这样做是为了在www和其他未来的应用程序/模块之间共享“服务”模块。

    应用程序结构

    |- www/
    |-- app/
    |--- src/
    |---- app.module.ts
    |- services/
    |-- app/
    |--- src/
    |---- services.module.ts
    

    Www模块

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    
    import { WwwComponent } from './www.component';
    import { ServicesModule | from './../../../services/app/src/services.module.ts';
    
    @NgModule({
      declarations: [
        WwwComponent
      ],
      imports: [
        BrowserModule,
        ServicesModule
      ],
      providers: [],
      bootstrap: [WwwComponent]
    })
    export class WwwModule { }
    

    服务模块

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule, ModuleWithProviders } from '@angular/core';
    import { HttpClientModule } from '@angular/common/http';
    import { RouterModule } from '@angular/router';
    
    import { ServicesComponent } from './services.component';
    
    import { AuthService } from '../auth.service';
    import { HttpService } from '../http.service';
    import { TemplateService } from '../template/template.service';
    import { ModalService } from '../modal/modal.service';
    
    @NgModule({
        declarations: [
            ServicesComponent
        ],
        exports: [
            ServicesComponent
        ],
        imports: [
            BrowserModule,
            RouterModule,
            HttpClientModule
        ],
        providers: [
            AuthService,
            HttpService,
            TemplateService,
            ModalService
        ],
        bootstrap: [ServicesComponent]
    })
    export class ServicesModule {}
    

    我跑步时犯的错误 ng构建 是:

    1. decorators中不支持函数调用,但调用了“ServicesModule”。

    有人看到我在角度应用程序中加入另一个角度模块的错误吗?

    1 回复  |  直到 6 年前
        1
  •  0
  •   RoboBear    6 年前

    因为我使用的是SVN,不想签出project/app目录中的共享模块,所以我将src/从Services模块复制到www/app/src/文件夹中,并从那里包含Services模块。

    |- www/
    |-- app/
    |--- src/
    |---- app.module.ts
    |--- services/
    |---- app/
    |----- services.module.ts
    

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    
    import { WwwComponent } from './www.component';
    import { ServicesModule | from './../services/app/src/services.module.ts';
    
    @NgModule({
      declarations: [
        WwwComponent
      ],
      imports: [
        BrowserModule,
        ServicesModule
      ],
      providers: [],
      bootstrap: [WwwComponent]
    })
    export class WwwModule { }
    

    作为参考,这些链接为我指明了正确的方向:

    1. https://groups.google.com/forum/#!topic/angular/WUdr1ra0WF0
    2. AOT Compiling and Modules References