ماذا تعرف عن Route و Location في Angular
الحقن:
constructor(
private cdref: ChangeDetectorRef,
public _router: Router,
public _location: Location,
public translateService: TranslateService,
public localStorageService: LocalStorageService,
private authenticationService: AuthenticationService
) {
this.authenticationService.user.subscribe(x => this.user = x);
}
الانتقال إلى وجهة:
refresh(): void {
this._router.navigateByUrl("/login", { skipLocationChange: true }).then(() => {
this._router.navigate(([decodeURI(this._location.path())]))
}
)
}
الانتقال إلى الخلف:
createNewEmployee(){
this.employeeCardsService.postItemWithSubscribe(this.employee, true, this.addNewEmployeeSuccess.nativeElement.value,'')
this._router.navigateByUrl("..").then(() => {
});
}
أو
import { Location } from '@angular/common';
constructor(private location: Location) { }
goBack() {
this.location.back();
}
تعليقات
إرسال تعليق