Angular 6 Error: Failed to parse template. Unable to establish a connection with 'routerLink' as it is not recognized as a valid property of 'a'

During app testing with npm test

An error is encountered :

Failed: Template parse errors:
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("
    <nav>
      <ul>
        <li><a class="nav-link active" [ERROR ->][routerLink]="['/movies']" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}" c"): ng:///DynamicTestModule/AppComponent.html@4:39
Can't bind to 'routerLinkActiveOptions' since it isn't a known property of 'a'. ("l>
        <li><a class="nav-link active" [routerLink]="['/movies']" routerLinkActive="active-link" [ERROR ->][routerLinkActiveOptions]="{exact: true}" class="fa fa-home"><span>Home</span></a></li>
        <li><"): ng:///DynamicTestModule/AppComponent.html@4:97
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("uterLinkActiveOptions]="{exact: true}" class="fa fa-home"><span>Home</span></a></li>
        <li><a [ERROR ->][routerLink]="['/movies']" class="fa fa-film"><span>Best Movies 200's</span></a></li>
        <li><a "): ng:///DynamicTestModule/AppComponent.html@5:15
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("routerLink]="['/movies']" class="fa fa-film"><span>Best Movies 200's</span></a></li>
        <li><a [ERROR ->][routerLink]="['/theatre']" class="fa fa-television"><span>Movies in Theatre</span></a></li>
        "): ng:///DynamicTestModule/AppComponent.html@6:15
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("ink]="['/theatre']" class="fa fa-television"><span>Movies in Theatre</span></a></li>
        <li><a [ERROR ->][routerLink]="['/tvshows']" class="fa fa-video-camera"><span>Tv Shows</span></a></li>
        <li><a "): ng:///DynamicTestModule/AppComponent.html@7:15
'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. ("

<div class="container">
  [ERROR ->]<router-outlet></router-outlet>
</div>"): ng:///DynamicTestModule/AppComponent.html@15:2

The provided HTML file is used in the app.

<section>
  <div class="tabs tabs-style-fillup">
    <nav>
      <ul>
        <li><a class="nav-link active" [routerLink]="['/movies']" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}" class="fa fa-home"><span>Home</span></a></li>
        <li><a [routerLink]="['/movies']" class="fa fa-film"><span>Best Movies 200's</span></a></li>
        <li><a [routerLink]="['/theatre']" class="fa fa-television"><span>Movies in Theatre</span></a></li>
        <li><a [routerLink]="['/tvshows']" class="fa fa-video-camera"><span>Tv Shows</span></a></li>
        <li><a href="#section-fillup-5" class="fa fa-gear"><span>Settings</span></a></li>
      </ul>
    </nav>
  </div><!-- /tabs -->
</section>

<div class="container">
  <router-outlet></router-outlet>
</div>

The main app module file is as follows:

    [Angular code snippet]

The custom routing module file:

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
    [Angular code snippet]

Question:

What could be the issue with the provided codes?

Answer №1

Ensure to include the RouterTestingModule in your testing specification file.

TestBed.configureTestingModule({
    .......
     imports: [
         RouterTestingModule,
         ......
     ],
     schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
     ......
})

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Passing a click event to a reusable component in Angular 2 for enhanced functionality

I am currently working on abstracting out a table that is used by several components. While most of my dynamic table population needs have been met, I am facing a challenge with making the rows clickable in one instance of the table. Previously, I simply ...

Attempting to transfer files to and from Firebase storage

Having trouble with my React Native app. I am trying to upload files, whether they are pictures or PDFs, but once uploaded, I can't seem to open them. However, "The files are getting uploaded to the storage." export const uploadToStorage = async (docu ...

Evaluating string combinations in JavaScript using valid comparisons

After choosing values on the screen, two variables store their value. var uval = '100'; var eval = '5'; There are 2 combinations with values: let combination1= 'u:100;e:1,4,5,10' let combination2 = 'u:1000;e:120,400,500, ...

Having trouble importing SVG as a React component in Next.js

I initially developed a project using create-react-app with Typescript, but later I was tasked with integrating next.js into it. Unfortunately, this caused some SVGs throughout the application to break. To resolve this issue, I implemented the following pa ...

Angular HttpClient does not support cross-domain POST requests, unlike jQuery which does

I am transitioning to Angular 13 and I want to switch from using jQuery.ajax to HttpClient. The jquery code below is currently functional: function asyncAjax(url: any){ return new Promise(function(resolve, reject) { $.ajax({ type: ...

Using `publishReplay()` and `refCount()` in Angular does not behave as anticipated when dealing with subscriptions across multiple components

I am currently investigating the functionality of publishReplay in rxjs. I have encountered an example where it behaves as expected: const source = new Subject() const sourceWrapper = source.pipe( publishReplay(1), refCount() ) const subscribeTest1 = ...

Issue encountered during the creation of a new Angular application (npm ERROR! 404 Not Found: @angular/animations@~7.1.0.)

I am currently using Windows 10, Node v11.0.0, and Angular CLI: 7.1.4. I encountered an error when trying to create a new Angular application. The error message is npm ERR! code E404 npm ERR! 404 Not Found: @angular/animations@~7.1.0. Error stack: 0 info ...

Before loading a deep link, use pre-CanActivate or pre-CanLoad

In my current project, I am faced with a challenging task of transitioning from Adobe Flash & Flex applications on a ColdFusion 11 backend to Angular applications. The expectation is that users will already be logged in and have an active session before a ...

Collaborative Vue component: Clients need to manually import the CSS

I recently created a Vue component using TypeScript that resulted in a separate CSS file being generated after the build process. However, I noticed that when the client imports this component, the CSS file is not imported automatically and needs to be exp ...

Receiving warnings during npm installation and encountering difficulties with fixing issues using npm audit fix

Currently, I am working on developing an Angular application with a .NET Core Web API integration. Upon cloning the repository, I attempted to execute 'npm install' for the Angular application, but encountered an unexpected error: npm install n ...

Firebase Angular encountering issues with AngularFirestoreModule

I have encountered a challenge with Firebase authentication in my Angular applications. Due to updated read and write rules that require auth!=null, I successfully implemented Firebase authentication in one of my apps using Angular 13. Now, I am trying to ...

Caution: The complete loading of /node_modules/ag-grid-angular/main.js for source-map flattening is not possible

While building the application using Angular Cli version 9.1.7 with enableIvy, I encountered a warning message. The application utilizes ag-grid-community version 22.1.0. The warning states: "Warning: Unable to fully load /node_modules/ag-grid-angular/mai ...

Creating a personal TypeScript language service extension in Visual Studio Code

Currently, I am working on developing a TSserver plugin in VSCode and struggling to get the server to load my plugin. I have experimented with setting the path in tsconfig.json to both a local path and a path to node_modules, but it still isn't worki ...

Error message: NextJs throws aReferenceError when trying to access the document object on page refresh

encountered the error ReferenceError: document is not defined when attempting to refresh the page I am working on creating a component using react-quill and then calling that component within a page. This is my component : import React, { useState } from ...

Add a css class to a <div> that is created by an <ng-template> inside the <ngx-datatable-column> element

I am struggling to implement the display: flex style on the parent <div> containing my <span> However, since the <span> is dynamically generated by the ng-template of the ngx-datatable-column, I'm finding it challenging to apply thi ...

What is the method to utilize global mixin methods within a TypeScript Vue component?

I am currently developing a Vue application using TypeScript. I have created a mixin (which can be found in global.mixin.js) and registered it using Vue.mixin() (as shown in main.ts). Content of global.mixin.js: import { mathHttp, engHttp } from '@/ ...

Preventing text from wrapping in a TypeScript-generated form: Tips and tricks

I’m currently working on a ReactJS project and my objective is simple: I want all three <FormItem> components to be displayed in a single line without wrapping. However, I am facing the following output: https://i.stack.imgur.com/mxiIE.png Within ...

Can anyone suggest a simpler method for creating function signatures with multiple conditions?

In my function, the first argument now determines if the function should receive an array or not. This function is similar to Foo type stringF = (arr: false, type: 'str', value: string) => void type numberF = (arr, false, type: 'num&apo ...

How can I utilize a filter or pipe to populate product categories onto screens within Ionic 2?

I am considering creating an Ionic 2 app with 6 pages, but I'm unsure whether to utilize a Pipe or a Filter for the individual category pages and how to implement the necessary code. Each category page should be able to display products from the "app ...

bidirectional data binding with programmatically generated input boxes

Is it possible to achieve two-way binding with dynamically created checkboxes? quali=[{class:"10",checked:false},{class:"12",checked:true},{class:"others",checked:true}]; <span *ngFor="let q_list of quali; let i=index" class="lists">  <in ...