turbogui-angular 20.0.0 → 20.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1673,6 +1673,26 @@ class RouterBaseService {
|
|
|
1673
1673
|
getCurrentRoute() {
|
|
1674
1674
|
return this._currentRoute.getValue();
|
|
1675
1675
|
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Gets the value of a specific route parameter by its key from the current route.
|
|
1678
|
+
*
|
|
1679
|
+
* For example, if the current route is `/user/123`, and you call this method with `key` as `id`, it will return `123`.
|
|
1680
|
+
* The name of the parameter must match the one defined in the route configuration on your application (e.g., `{ path: 'user/:id', component: UserComponent }`).
|
|
1681
|
+
*
|
|
1682
|
+
* @param key The key of the route parameter to retrieve.
|
|
1683
|
+
*
|
|
1684
|
+
* @returns The value of the specified route parameter, or undefined if it does not exist.
|
|
1685
|
+
*/
|
|
1686
|
+
getCurrentRouteParamValue(key) {
|
|
1687
|
+
let currentRoute = this.router.routerState.snapshot.root;
|
|
1688
|
+
while (currentRoute.firstChild) {
|
|
1689
|
+
currentRoute = currentRoute.firstChild;
|
|
1690
|
+
}
|
|
1691
|
+
if (!(key in currentRoute.params)) {
|
|
1692
|
+
throw new Error(`Route parameter '${key}' does not exist.`);
|
|
1693
|
+
}
|
|
1694
|
+
return currentRoute.params[key];
|
|
1695
|
+
}
|
|
1676
1696
|
/**
|
|
1677
1697
|
* Initializes the title management feature to automatically refresh the browser title based on the current
|
|
1678
1698
|
* URL route. It Must be called once, typically at application startup
|