שאלו את שאלתכם וקבלו סיכום של המסמך על ידי הפניה לדף הזה ולספק ה-AI שתבחרו
היסטוריית גרסאות
- "Add usePathname utility"v10.0.023.6.2026
- "Init history"v8.2.022.6.2026
התוכן של הדף הזה תורגם באמצעות AI.
צפייה בגרסה האחרונה של התוכן המקורי באנגליתאם יש לכם רעיון לשיפור התיעוד הזה, אל תהססו לתרום על ידי הגשת Pull Request ב-GitHub.
קישור GitHub לתיעודהעתקת ה-Markdown של המסמך ללוח
Angular Integration: usePathname Hook Documentation
The usePathname hook returns the current browser pathname with the locale segment stripped, as an Angular Signal<string>. It is useful for building locale-aware navigation (for example, determining which nav item is active) without having to manually remove the locale prefix.
Importing usePathname in Angular
העתקת הקוד ללוח
Overview
usePathname reads window.location.pathname, strips the locale prefix via getPathWithoutLocale, and updates the signal whenever the browser fires a popstate event (back/forward navigation). It uses Angular's DestroyRef to clean up the event listener automatically when the component is destroyed.
Usage
העתקת הקוד ללוח
Return Value
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Type | Description |
|---|---|
Signal<string> | Angular signal containing the current pathname without the locale prefix. |
Behavior
- Locale stripping: Removes the leading locale segment (e.g.
/fr/dashboard→/dashboard). - Reactive: Updates automatically on
popstateevents (browser back / forward navigation). - SSR-safe: Returns
""whenwindowis not available. - Cleanup: The
popstatelistener is removed viaDestroyRef.onDestroywhen the host component is destroyed.
Example
העתקת הקוד ללוח
