I recently had a problem with the CanActivate annotation since I migrated from version 4 of AngularDart. Indeed, the CanActivate annotation does not run. My Code :
import 'dart:html' as html;
import 'package:angular/angular.dart';
import 'package:angular_router/angular_router.dart';
import 'package:maho_enterprise/app_component.dart';
// Others import
@Component(selector: "view-main"
,templateUrl: "main_component.html"
,styleUrls: const ["main_component.css"]
,directives: const [TopBarComponent,SideBarComponent])
@CanActivate(verifyIfUserIfAuthenticate)
class MainComponent {
}
bool verifyIfUserIfAuthenticate(ComponentInstruction next, ComponentInstruction prev) {
html.window.console.info("CanActivate works correctly");
AuthenticationService service = new AuthenticationService.empty();
bool connected = service.isConnected();
html.window.console.info("Value connected : "+connected.toString());
if(!connected) {
Router router = myInjector.get(Router);
router.navigateByUrl("/login");
return false;
}
return true;
}
Has anyone encountered this problem with version 4 of AngularDart? thanks for the help.