This is the error I get:
(这是我得到的错误:)
No template specified for component PageNotFoundComponent Error: No template specified for component PageNotFoundComponent at DirectiveNormalizer.normalizeDirective
(没有为组件PageNotFoundComponent指定模板,错误:没有在DirectiveNormalizer.normalizeDirective为组件PageNotFoundComponent指定模板。)
This module /
component redirect user to homepage and logs them out if route doesnt exist eg **
(该模块/
组件将用户重定向到主页,如果路由不存在则将其注销,例如**
)
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 { }
This is 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) Could not compile 'PageNotFoundDirective' because it is not a component.
((索引):95错误:(SystemJS)无法编译'PageNotFoundDirective',因为它不是组件。)
Error: Could not compile 'PageNotFoundDirective' because it is not a component. (错误:无法编译“ PageNotFoundDirective”,因为它不是组件。)
ask by AngularM translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…