This is the error I get:
No template for PageNotFoundComponent component Error: No template specified for PageNotFoundComponent component in DirectiveNormalizer.normalizeDirective
This module / component redirects the user to the main page and registers them if the route does not exist, for example. **
This is my component:
import { Directive} from '@angular/core'; import { Router } from '@angular/router'; import { AuthService } from '../../services/authService/authService'; @Directive({ selector: 'PageNotFoundComponent' }) export class PageNotFoundDirective { constructor(_authService: AuthService, _router: Router){ _authService.isAuthenticated().then(() => { _router.navigate(['/home']); }); } }
This is my module.
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterModule } from '@angular/router'; import { PageNotFoundDirective } from './pageNotFound.directive'; import { AuthService } from '../../services/authService/authService'; @NgModule({ imports: [CommonModule, RouterModule], declarations: [PageNotFoundDirective], exports: [PageNotFoundDirective], providers: [AuthService] }) export class PageNotFoundModule { }
These are my routes:
import { Route } from '@angular/router'; import { PageNotFoundDirective } from './index'; export const PageNotFoundRoutes: Route[] = [ { path: '**', component: PageNotFoundDirective } ];
This is the current error I get:
(index): 95 Error: (SystemJS) Unable to compile 'PageNotFoundDirective' because it is not a component. Error: Failed to compile 'PageNotFoundDirective' because it is not a component.
source share