在angular2 rc1中,我订阅了路线的更改:
this.router.changes.subscribe(
() => {
console.log(this.location.path());
});
如何在angular2 rc3中订阅更改路线? router.changes已经不存在。
答案 0 :(得分:6)
constructor(router:Router) {
router.events.subscribe(event:Event => {
if(event instanceof NavigationStart) {
}
// NavigationEnd
// NavigationCancel
// NavigationError
// RoutesRecognized
}
}
或
constructor(router:Router) {
router.events.forEach(event:Event => {
答案 1 :(得分:3)
@derived_field(name = "bound_density", units = "g/cm**3")
def _get_ejected_density(field, data):
E = 0.5* data["cell_mass"]* (data["velx"]**2+data["vely"]**2+data["velz"]**2)+ data["gpot"]*data["cell_mass"]
return ((np.array(E)<0)*1)*data["density"]