ماذا تعرف عن 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();
}























تعليقات

المشاركات الشائعة من هذه المدونة

ngx-extended-pdf-viewer

how to getting access token for https://fcm.googleapis.com/v1/projects/al-ayahya-co/messages:send for angular and backend nestjs

طريقة تفعيل زر Inline Keyboard في Telegram Bot