Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'router-outlet' is not a known element in angular2

Tags:

angular

I've just created a new angular project using the Angular CLI and scaffolded a new route and I am getting error as :

'router-outlet' is not a known element

Can anyone help me ?

like image 680
NARGIS PARWEEN Avatar asked Oct 21 '16 04:10

NARGIS PARWEEN


People also ask

What is the router outlet?

Router-Outlet is an Angular directive from the router library that is used to insert the component matched by routes to be displayed on the screen.

What is router outlet in Angular 13?

RouterOutletlink Acts as a placeholder that Angular dynamically fills based on the current router state.

How to use router outlet in Angular 8?

The router-outlet is a directive that's available from the @angular/router package and is used by the router to mark where in a template, a matched component should be inserted. Thanks to the router outlet, your app will have multiple views/pages and the app template acts like a shell of your application.

Can we have multiple router outlet in Angular?

Angular Router supports multiple outlets in the same application. A component has one associated primary route and can have auxiliary routes. Auxiliary routes enable developers to navigate multiple routes at the same time.


1 Answers

Here is the solution that worked for me, inspired by gaurav2887 from this page:

import { RouterTestingModule } from '@angular/router/testing';
...    
beforeEach(() => {
        TestBed.configureTestingModule({
            declarations: [ MyComponent ],
            imports: [ RouterTestingModule ]
        });
...
like image 73
ThCollignon Avatar answered Nov 15 '22 02:11

ThCollignon