web: add helper to navigate with params
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
6b39d616b1
commit
210d4c5058
|
@ -30,6 +30,19 @@ window.addEventListener("load", () => {
|
||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export function paramURL(url: string, params?: { [key: string]: unknown }): string {
|
||||||
|
let finalUrl = "#";
|
||||||
|
finalUrl += url;
|
||||||
|
if (params) {
|
||||||
|
finalUrl += ";";
|
||||||
|
finalUrl += encodeURIComponent(JSON.stringify(params));
|
||||||
|
}
|
||||||
|
return finalUrl;
|
||||||
|
}
|
||||||
|
export function navigate(url: string, params?: { [key: string]: unknown }): void {
|
||||||
|
window.location.assign(paramURL(url, params));
|
||||||
|
}
|
||||||
|
|
||||||
@customElement("ak-router-outlet")
|
@customElement("ak-router-outlet")
|
||||||
export class RouterOutlet extends LitElement {
|
export class RouterOutlet extends LitElement {
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
|
|
Reference in New Issue