Skip to content

Instantly share code, notes, and snippets.

@ThomasHambach
Last active December 8, 2018 08:05
Show Gist options
  • Save ThomasHambach/fc1c25196424304d03f3b7e9725cec58 to your computer and use it in GitHub Desktop.
Save ThomasHambach/fc1c25196424304d03f3b7e9725cec58 to your computer and use it in GitHub Desktop.
Angular 1, Vue 2, ui-router control.
// 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);
});
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