3

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.

ufk
  • 30,912
  • 70
  • 235
  • 386

1 Answers1

3

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

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • 5
    Don't understand how this can possibly called a RC. – malifa May 18 '16 at 08:43
  • 1
    That was because of ng-conf. These guys are working really hard for us. We shouldn't be stingy when they announce RC a bit premature for such an important event. – Günter Zöchbauer May 20 '16 at 18:15
  • Also only Angular2 core is RC. The router (like http) are not considered part of core. They will be moved out as distinctive modules and versioned independently of Angular2 core eventually. They are currently only maintained inside the `angular` GitHub repository for convenience. – Günter Zöchbauer May 20 '16 at 20:33
  • Interesting, why did they "need" a RC for ng-conf? Would you expect another huge update for the ng-europe? (if yes, i would definititly attend the workshop there :) ). But well, you're right. Shouldn't be stingy, they are really fast paced update-wise. It wasn't they wisest choice to start a serious angular2 project anyway. – malifa May 21 '16 at 14:33
  • I don't know. I guess they assumed to be quite close to RC anyway and just used this event to make it a bigger announcement. – Günter Zöchbauer May 21 '16 at 15:54