У меня есть два Angular 0 проекта. Я пытаюсь переместить некоторый код из проекта1 в проект2. Код, который работает в проекте 1, не работает в проекте 2. Исследуя проблему, я сравниваю конфигурацию проектов. Итак,
project1:
Angular CLI: 9.0.1
Node: 10.15.1
OS: win32 x64
Angular: 9.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.1
@angular-devkit/build-angular 0.900.1
@angular-devkit/build-optimizer 0.900.1
@angular-devkit/build-webpack 0.900.1
@angular-devkit/core 9.0.1
@angular-devkit/schematics 9.0.1
@angular/cli 9.0.1
@angular/flex-layout 9.0.0-beta.29
@ngtools/webpack 9.0.1
@schematics/angular 9.0.1
@schematics/update 0.900.1
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
Как вы заметили, у него нет пакета Router, хотя маршрутизатор работает нормально.
project2:
Angular CLI: 9.1.1
Node: 10.15.1
OS: win32 x64
Angular: 9.1.2
... common, compiler, compiler-cli, core
Ivy Workspace: Yes
Package Version
-------------------------------------------------------------
@angular-devkit/architect 0.901.1
@angular-devkit/build-angular 0.901.1
@angular-devkit/build-ng-packagr 0.901.1
@angular-devkit/build-optimizer 0.901.1
@angular-devkit/build-webpack 0.901.1
@angular-devkit/core 9.1.1
@angular-devkit/schematics 9.1.1
@angular/animations 9.0.7
@angular/cdk 9.2.1
@angular/cli 9.1.1
@angular/flex-layout 9.0.0-beta.29
@angular/forms 9.0.7
@angular/language-service 9.0.7
@angular/material 9.2.1
@angular/platform-browser 9.0.7
@angular/platform-browser-dynamic 9.0.7
@angular/router 9.0.7
@ngtools/webpack 9.1.1
@schematics/angular 9.1.1
@schematics/update 0.901.1
ng-packagr 9.1.1
rxjs 6.5.5
typescript 3.7.5
webpack 4.42.0
Второй проект имеет пакет маршрутизатора.
Мой вопрос: имеет ли это какое-то значение с точки зрения конфигурации маршрутизатора?
Спасибо
Обновление. У меня есть следующий код в project1:
<nav mat-tab-nav-bar>
<a mat-tab-link
*ngFor="let link of navLinks"
[routerLink]="link.link"
routerLinkActive #rla="routerLinkActive"
[active]="rla.isActive">{{link.label}}
</a>
</nav>
, который работает нормально, но в project2 я получаю ошибки:
ERROR in projects/prism/src/app/top-navigation/top-navigation-component/top-navigation-component.html:4:5 - error NG8002: Can't bind to 'routerLink' since it isn't a known property of 'a'.
4 [routerLink]="link.link"
~~~~~~~~~~~~~~~~~~~~~~~~
projects/prism/src/app/top-navigation/top-navigation-component/top-navigation-component.ts:5:16
5 templateUrl: './top-navigation-component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component TopNavigationComponent.
projects/prism/src/app/top-navigation/top-navigation-component/top-navigation-component.html:6:5 - error NG8002: Can't bind to 'active' since it isn't a known property of 'a'.
6 [active]="rla.isActive">{{link.label}}
~~~~~~~~~~~~~~~~~~~~~~~
projects/prism/src/app/top-navigation/top-navigation-component/top-navigation-component.ts:5:16
5 templateUrl: './top-navigation-component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component TopNavigationComponent.
projects/prism/src/app/top-navigation/top-navigation-component/top-navigation-component.html:5:28 - error NG8003: No directive found with exportAs 'routerLinkActive'.
5 routerLinkActive #rla="routerLinkActive"
~~~~~~~~~~~~~~~~
projects/prism/src/app/top-navigation/top-navigation-component/top-navigation-component.ts:5:16
5 templateUrl: './top-navigation-component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component TopNavigationComponent.
Project1. Компонент модуля:
import { CommonModule } from '@angular/common';
import { SharedModule } from './../../shared/shared.module';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { SettingsComponent } from './settings.component';
import { Routes, RouterModule } from '@angular/router';
@NgModule({
imports: [
SharedModule,
CommonModule,
RouterModule
],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
declarations: [ SettingsComponent ]
})
export class SettingsModule { }