Last active
December 8, 2018 08:05
-
-
Save ThomasHambach/fc1c25196424304d03f3b7e9725cec58 to your computer and use it in GitHub Desktop.
Angular 1, Vue 2, ui-router control.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Vue path changer that ties in with ui-router. | |
// Add this somewhere, such as in your app runner, to catch the event. | |
addEventListener("requestPathChange", (e: CustomEventInit) => { | |
$state.go(e.detail.path, e.detail.params); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const go = (path: string, params: {[key: string]: string}) => { | |
const event = new CustomEvent("requestPathChange", { | |
detail: { | |
path: path, | |
params: params, | |
}, | |
}); | |
dispatchEvent(event); | |
}; | |
export interface INgRouter { | |
go: (path: string, params: { [key: string]: string }) => void; | |
} | |
declare module "vue/types/vue" { | |
// tslint:disable-next-line:interface-name | |
interface Vue { | |
$ngRouter: INgRouter; | |
} | |
} | |
export const NgRouter: INgRouter = { | |
go: go, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment