简体   繁体   中英

ComponentInstruction and CanActivate are not available in angular 2 rc1

I'm writing an angular2 application using typescript with angular 2 rc.1

I'm guessing that the angular 2 documents are not updated yet.

https://angular.io/docs/ts/latest/api/router/ComponentInstruction-interface.html

https://angular.io/docs/ts/latest/api/router/CanActivate-decorator.html

the ComponentInstruction Interface and CanActivate decorator are no longer available in angular2-rc.1. what is there instead ?

I have the following class that I need to upgrade to the latest angular version.

class RequireUserAnnotation extends CanActivate {
  constructor() {
    super(this.canProceed.bind(this));
  }

  canProceed(prev: ComponentInstruction,
         next: ComponentInstruction) {
    return !!Meteor.user();
  }
}

the new @angular/router package now has CanDeactivate and OnActivate. which confuses me a bit.

I guess that https://angular.io/docs/js/latest/api/router/CanDeactivate-interface.html is not updated also because it says that: The routerCanDeactivate hook is called with two ComponentInstructions as parameters , and ComponentInstruction is not defined anymore.

I don't want to use the angular/@router-deprecated package. i wanna fix this! please! :)

any information regarding the issue would be greatly appreciated.

This has yet to be implemented. See https://github.com/angular/angular/issues/4015#issuecomment-217678683

Did anyone attend Brandon's workshop ( https://www.ng-conf.org/#/sessions/bdogg64FD ) yesterday? It was scheduled to discuss "resolving data before loading routes", and appears to have been using the new-new router (with CanActivate moved/relocated).

I attended :smile: I didn't cover resolving data before loading routes because that mechanism doesn't exist in the new router yet.

Maybe also https://github.com/angular/angular/issues/7784#issuecomment-217912079

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM