mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 19:17:30 +00:00
Update remaining templates to TypeScript 2 / @types / etc.
This commit is contained in:
committed by
SteveSandersonMS
parent
a7ed0112db
commit
f6d7321243
@@ -1,8 +1,8 @@
|
||||
import './css/site.css';
|
||||
import * as ko from 'knockout';
|
||||
import { createHistory } from 'history';
|
||||
import './webpack-component-loader';
|
||||
import AppRootComponent from './components/app-root/app-root';
|
||||
const createHistory = require('history').createBrowserHistory;
|
||||
|
||||
// Load and register the <app-root> component
|
||||
ko.components.register('app-root', AppRootComponent);
|
||||
|
||||
@@ -13,7 +13,7 @@ class AppRootViewModel {
|
||||
public route: KnockoutObservable<Route>;
|
||||
private _router: Router;
|
||||
|
||||
constructor(params: { history: HistoryModule.History }) {
|
||||
constructor(params: { history: History.History }) {
|
||||
// Activate the client-side router
|
||||
this._router = new Router(params.history, routes)
|
||||
this.route = this._router.currentRoute;
|
||||
|
||||
@@ -15,7 +15,7 @@ export class Router {
|
||||
private disposeHistory: () => void;
|
||||
private clickEventListener: EventListener;
|
||||
|
||||
constructor(history: HistoryModule.History, routes: Route[]) {
|
||||
constructor(history: History.History, routes: Route[]) {
|
||||
// Reset and configure Crossroads so it matches routes and updates this.currentRoute
|
||||
crossroads.removeAllRoutes();
|
||||
crossroads.resetState();
|
||||
@@ -38,8 +38,11 @@ export class Router {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$(document).on('click', 'a', this.clickEventListener);
|
||||
|
||||
// Initialize Crossroads with starting location
|
||||
// Need to cast history to 'any' because @types/history is out-of-date
|
||||
crossroads.parse((history as any).location.pathname);
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
|
||||
Reference in New Issue
Block a user