I am currently facing an issue with the latest versions of Angular 2 (2.0.1) and angular router : 3.0.1
Upon running the application, I encounter the following error message: Error: (SystemJS) No Directive annotation found on LoginGuard(…)
The problem lies within a router that uses a canActivate class to control access to routes. Below is the code snippet :
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
export const MainWindowRoutes = [
{
path: '',
redirectTo: '/web-portal',
pathMatch: 'full'
},
// Include more route definitions here...
];
// Remaining code snippets...
The LoginGuard class is crucial for handling user authentication before accessing certain routes. The implementation of this class can be seen below :
import { Injectable } from '@angular/core';
import {
CanActivate,
Router,
ActivatedRouteSnapshot,
RouterStateSnapshot } from '@angular/router';
// More imports and class definition...
In my app.module file, I initiate the router as follows :
// Code snippet showing how the router is initialized
Unfortunately, the injection process does not seem to work properly for the canActivate class (LoginGuard).
If anyone has insights or solutions to this issue, please share them! 😊
Thank you!