首页 > 解决方案 > 无法编译项目 Angular 错误 NG8002、8001

问题描述

我无法编译程序,出现上述错误,我在文件中添加了所有这些内容和问题。我添加了 ngx-gallery 模块,之后我什么也做不了,即使我尝试撤消更改,我也有同样的事情。你能帮我吗?

我有这个问题:

ERROR in node_modules/@auth0/angular-jwt/index.d.ts:19:48 - error NG6005: JwtModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.
    
    19     static forRoot(options: JwtModuleOptions): ModuleWithProviders;
                                                      ~~~~~~~~~~~~~~~~~~~
    src/app/members/member-detail/member-detail.component.html:34:17 - error NG8001: 'tabset' is not a known element:
    1. If 'tabset' is an Angular component, then verify that it is part of this module.
    2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    34                 <tabset class="member-tabset">
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:35:21 - error NG8001: 'tab' is not a known element:
    1. If 'tab' is an Angular component, then verify that it is part of this module.
    2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    35                     <tab heading="About {{user?.knownAs}}">
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        120m   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:35:26 - error NG8002: Can't bind to 'heading' since it isn't a known property of 'tab'.
    
    35                     <tab heading="About {{user?.knownAs}}">
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:41:21 - error NG8001: 'tab' is not a known element:
    1. If 'tab' is an Angular component, then verify that it is part of this module.
    2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    41                     <tab heading="Interests">
                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:45:21 - error NG8001: 'tab' is not a known element:
    1. If 'tab' is an Angular component, then verify that it is part of this module.
    2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    45                     <tab heading="Photos">
                           ~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:46:25 - error NG8001: 'ngx-gallery' is not a known element:
    1. If 'ngx-gallery' is an Angular component, then verify that it is part of this module.
    2. If 'ngx-gallery' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    
    46                         <ngx-gallery [options]="galleryOptions" [images]="galleryImages"></ngx-gallery>
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:46:38 - error NG8002: Can't bind to 'options' since it isn't a known property of 'ngx-gallery'.
    1. If 'ngx-gallery' is an Angular component and it has 'options' input, then verify that it is part of this module.
    2. If 'ngx-gallery' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    46                         <ngx-gallery [options]="galleryOptions" [images]="galleryImages"></ngx-gallery>
                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:46:65 - error NG8002: Can't bind to 'images' since it isn't a known property of 'ngx-gallery'.
    1. If 'ngx-gallery' is an Angular component and it has 'images' input, then verify that it is part of this module.
    2. If 'ngx-gallery' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    46                         <ngx-gallery [options]="galleryOptions" [images]="galleryImages"></ngx-gallery>
                                                                       ~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:48:21 - error NG8001: 'tab' is not a known element:
    1. If 'tab' is an Angular component, then verify that it is part of this module.
    2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    48                     <tab heading="Messages">
                           ~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-card/member-card.component.html:5:74 - error NG8002: Can't bind to 'routerLink' since it isn't a known property of 'button'.
    
    5             <li class="list-inline-item"><button class="btn btn-primary" [routerLink]="['/members/', user.id]"><i class="fa fa-user"></i></button></li>
                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-card/member-card.component.ts:7:16
        7   templateUrl: './member-card.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberCardComponent.
    src/app/app.component.html:9:1 - error NG8001: 'app-nav' is not a known element:
    1. If 'app-nav' is an Angular component, then verify that it is part of this module.
    2. If 'app-nav' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    
    9 <app-nav></app-nav>
      ~~~~~~~~~~~~~~~~~~~
    
      src/app/app.component.ts:8:16
        8   templateUrl: './app.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component AppComponent.
    src/app/app.component.html:10:1 - error NG8001: 'router-outlet' is not a known element:
    1. If 'router-outlet' is an Angular component, then verify that it is part of this module.
    2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    
    10 <router-outlet></router-outlet>
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/app.component.ts:8:16
        8   templateUrl: './app.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component AppComponent.
    src/app/nav/nav.component.html:3:33 - error NG8002: Can't bind to 'routerLink' since it isn't a known property of 'a'.
    
    3         <a class="navbar-brand" [routerLink]="['/home']">Dating App</a>
                                      ~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/nav/nav.component.ts:8:16
        8   templateUrl: './nav.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component NavComponent.
    src/app/register/register.component.html:6:74 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.
    
    6         <input type="text" class="form-control" required name="username" [(ngModel)]="model.username" placeholder="Username">
                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/register/register.component.ts:8:16
        8   templateUrl: './register.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component RegisterComponent.
    src/app/register/register.component.html:11:78 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.
    
    11         <input type="password" class="form-control" required name="password" [(ngModel)]="model.password" placeholder="Password">
                                                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/register/register.component.ts:8:16
        8   templateUrl: './register.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component RegisterComponent.
    src/app/register/register.component.html:1:22 - error NG8003: No directive found with exportAs 'ngForm'.
    
    1 <form #registerForm="ngForm" (ngSubmit)="register()">
                           ~~~~~~
    
      src/app/register/register.component.ts:8:16
        8   templateUrl: './register.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component RegisterComponent.
    
    
    ERROR in node_modules/@auth0/angular-jwt/index.d.ts:19:48 - error NG6005: JwtModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.
    
    19     static forRoot(options: JwtModuleOptions): ModuleWithProviders;
                                                      ~~~~~~~~~~~~~~~~~~~
    src/app/members/member-detail/member-detail.component.html:34:17 - error NG8001: 'tabset' is not a known element:
    1. If 'tabset' is an Angular component, then verify that it is part of this module.
    2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    34                 <tabset class="member-tabset">
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:35:21 - error NG8001: 'tab' is not a known element:
    1. If 'tab' is an Angular component, then verify that it is part of this module.
    2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    35                     <tab heading="About {{user?.knownAs}}">
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        120m   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:35:26 - error NG8002: Can't bind to 'heading' since it isn't a known property of 'tab'.
    
    35                     <tab heading="About {{user?.knownAs}}">
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:41:21 - error NG8001: 'tab' is not a known element:
    1. If 'tab' is an Angular component, then verify that it is part of this module.
    2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    41                     <tab heading="Interests">
                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:45:21 - error NG8001: 'tab' is not a known element:
    1. If 'tab' is an Angular component, then verify that it is part of this module.
    2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    45                     <tab heading="Photos">
                           ~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:46:25 - error NG8001: 'ngx-gallery' is not a known element:
    1. If 'ngx-gallery' is an Angular component, then verify that it is part of this module.
    2. If 'ngx-gallery' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    
    46                         <ngx-gallery [options]="galleryOptions" [images]="galleryImages"></ngx-gallery>
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:46:38 - error NG8002: Can't bind to 'options' since it isn't a known property of 'ngx-gallery'.
    1. If 'ngx-gallery' is an Angular component and it has 'options' input, then verify that it is part of this module.
    2. If 'ngx-gallery' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    46                         <ngx-gallery [options]="galleryOptions" [images]="galleryImages"></ngx-gallery>
                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:46:65 - error NG8002: Can't bind to 'images' since it isn't a known property of 'ngx-gallery'.
    1. If 'ngx-gallery' is an Angular component and it has 'images' input, then verify that it is part of this module.
    2. If 'ngx-gallery' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    46                         <ngx-gallery [options]="galleryOptions" [images]="galleryImages"></ngx-gallery>
                                                                       ~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-detail/member-detail.component.html:48:21 - error NG8001: 'tab' is not a known element:
    1. If 'tab' is an Angular component, then verify that it is part of this module.
    2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
    
    48                     <tab heading="Messages">
                           ~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-detail/member-detail.component.ts:12:16
        12   templateUrl: './member-detail.component.html',
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberDetailComponent.
    src/app/members/member-card/member-card.component.html:5:74 - error NG8002: Can't bind to 'routerLink' since it isn't a known property of 'button'.
    
    5             <li class="list-inline-item"><button class="btn btn-primary" [routerLink]="['/members/', user.id]"><i class="fa fa-user"></i></button></li>
                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/members/member-card/member-card.component.ts:7:16
        7   templateUrl: './member-card.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component MemberCardComponent.
    src/app/app.component.html:9:1 - error NG8001: 'app-nav' is not a known element:
    1. If 'app-nav' is an Angular component, then verify that it is part of this module.
    2. If 'app-nav' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    
    9 <app-nav></app-nav>
      ~~~~~~~~~~~~~~~~~~~
    
      src/app/app.component.ts:8:16
        8   templateUrl: './app.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component AppComponent.
    src/app/app.component.html:10:1 - error NG8001: 'router-outlet' is not a known element:
    1. If 'router-outlet' is an Angular component, then verify that it is part of this module.
    2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    
    10 <router-outlet></router-outlet>
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/app.component.ts:8:16
        8   templateUrl: './app.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component AppComponent.
    src/app/nav/nav.component.html:3:33 - error NG8002: Can't bind to 'routerLink' since it isn't a known property of 'a'.
    
    3         <a class="navbar-brand" [routerLink]="['/home']">Dating App</a>
                                      ~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/nav/nav.component.ts:8:16
        8   templateUrl: './nav.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component NavComponent.
    src/app/register/register.component.html:6:74 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.
    
    6         <input type="text" class="form-control" required name="username" [(ngModel)]="model.username" placeholder="Username">
                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      src/app/register/register.component.ts:8:16
        8   templateUrl: './register.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component RegisterComponent.
    src/app/register/register.component.html:11:78 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.

    11         <input type="password" class="form-control" required name="password" [(ngModel)]="model.password" placeholder="Password">
                                                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      src/app/register/register.component.ts:8:16
        8   templateUrl: './register.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component RegisterComponent.
    src/app/register/register.component.html:1:22 - error NG8003: No directive found with exportAs 'ngForm'.

    1 <form #registerForm="ngForm" (ngSubmit)="register()">
                           ~~~~~~

      src/app/register/register.component.ts:8:16
        8   templateUrl: './register.component.html',
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Error occurs in the template of component RegisterComponent.

这是我的 package.json:

{
    "name": "dating-app-spa",
    "version": "0.0.0",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e",
        "postinstall": "ngcc"
    },
    "private": true,
    "dependencies": {
        "@agm/core": "^3.0.0-beta.0",
        "@angular/animations": "^10.1.5",
        "@angular/common": "^10.1.5",
        "@angular/compiler": "^10.1.5",
        "@angular/core": "^10.1.5",
        "@angular/forms": "^10.1.5",
        "@angular/platform-browser": "^10.1.5",
        "@angular/platform-browser-dynamic": "^10.1.5",
        "@angular/router": "^10.1.5",
        "@auth0/angular-jwt": "^2.1.2",
        "alertifyjs": "^1.13.1",
        "bootstrap": "^4.5.3",
        "bootswatch": "^4.5.2",
        "font-awesome": "^4.7.0",
        "lodash-es": "^4.17.15",
        "ngx-bootstrap": "^5.5.0",
        "ngx-gallery": "^5.10.0",
        "rxjs": "~6.5.5",
        "tslib": "^2.0.3",
        "zone.js": "~0.10.3"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "~0.1000.5",
        "@angular/cli": "~10.0.5",
        "@angular/compiler-cli": "~10.0.6",
        "@types/node": "^12.11.1",
        "@types/jasmine": "~3.5.0",
        "@types/jasminewd2": "~2.0.3",
        "codelyzer": "^6.0.0",
        "jasmine-core": "~3.5.0",
        "jasmine-spec-reporter": "~5.0.0",
        "karma": "~5.0.0",
        "karma-chrome-launcher": "~3.1.0",
        "karma-coverage-istanbul-reporter": "~3.0.2",
        "karma-jasmine": "~3.3.0",
        "karma-jasmine-html-reporter": "^1.5.0",
        "protractor": "~7.0.0",
        "ts-node": "~8.3.0",
        "tslint": "~6.1.0",
        "typescript": "~3.9.5"
    }
}

app.module.ts

import { MemberListResolver } from './_resolvers/member-list.resolver';
import { MemberDetailResolver } from './_resolvers/member-detail.resolver';
import { UserService } from './_services/user.service';
import { AuthGuard } from './_guards/auth.guard';
import { AlertifyService } from './_services/alertify.service';
import { MemberDetailComponent } from './members/member-detail/member-detail.component';
import { MemberCardComponent } from './members/member-card/member-card.component';
import { appRoutes } from './routes';
import { ErrorInterceptorProvider } from './_services/error.interceptor';
import { AuthService } from './_services/auth.service';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import {FormsModule} from '@angular/forms';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { RouterModule } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { NavComponent } from './nav/nav.component';
import { RegisterComponent } from './register/register.component';
import { HomeComponent } from './home/home.component';
import { MemberListComponent } from './members/member-list/member-list.component';
import { ListsComponent } from './lists/lists.component';
import { MessagesComponent } from './messages/messages.component';
import { JwtModule } from '@auth0/angular-jwt';
import { TabsModule } from 'ngx-bootstrap/tabs';
import { NgxGalleryModule } from 'ngx-gallery';



// tslint:disable-next-line:typedef
export function tokenGetter() {
  return localStorage.getItem('token');
}

@NgModule({
   declarations: [
      AppComponent,
      NavComponent,
      RegisterComponent,
      HomeComponent,
      MemberListComponent,
      ListsComponent,
      MessagesComponent,
      MemberCardComponent,
      MemberDetailComponent
   ],
   imports: [
      BrowserModule,
      HttpClientModule,
      BrowserAnimationsModule,
      FormsModule,
      BsDropdownModule.forRoot(),
      TabsModule.forRoot(),
      RouterModule.forRoot(appRoutes),
      NgxGalleryModule,
      JwtModule.forRoot({
        config: {
          // tslint:disable-next-line:object-literal-shorthand
          tokenGetter: tokenGetter,
          whitelistedDomains: ['localhost:5000'],
          blacklistedRoutes: ['localhost:5000/api/auth']
        }
      })
   ],
   providers: [
      AuthService,
      ErrorInterceptorProvider,
      AlertifyService,
      AuthGuard,
      UserService,
      MemberDetailResolver,
      MemberListResolver
   ],
   bootstrap: [
      AppComponent
   ]
})
export class AppModule { }

标签: angular

解决方案


显然基于这个Github 问题,Angular Ivy 遇到了ngx-gallery另一个版本的问题,ngx-gallery 的 npm 页面也说

关闭至 11.06.2018

这个包已经过时了

所以我建议

  1. 删除nodes_modules目录
  2. npm install
  3. npm uninstall ngx-gallery
  4. npm install @kolkov/ngx-gallery --save

对于较新版本的 Angular,此版本似乎更好。


推荐阅读