5
To jest moja obecna próba użycia starych bibliotek.W kanciastym 2, w jaki sposób można wykryć zmiany trasy
jestem teraz przy użyciu najnowszych bibliotekami, w jaki sposób mogę zaktualizować to:
import { Component, } from '@angular/core';
import { Location } from '@angular/common';
import { Router } from '@angular/router';
@Component({
moduleId: module.id,
selector: 'HeaderComponent',
templateUrl: 'header.component.html'
})
export class HeaderComponent{
router : Router;
constructor(router: Router, location: Location){
this.router = router;
this.router.changes.subscribe((currentRoute) => {
let currentRoute = this.location.path();
})
}
}
To mój moduł:
export * from './header.component';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { HeaderComponent } from './header.component';
@NgModule({
imports: [RouterModule, CommonModule],
declarations: [HeaderComponent],
exports: [HeaderComponent],
providers: []
})
export class HeaderModule { }
To wydaje się działać dobrze. this.location.path() nie działa z nowymi bibliotekami, żadnymi pomysłami? jego w powyższym kodzie i narzekać na ścieżkę – AngularM
'this.location.path()' powinien działać https://angular.io/docs/ts/latest/api/common/index/Location-class.html –
to działa w porządku, miałem to poza zakresem – AngularM