-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlegacy.routes.ts
33 lines (27 loc) · 1.03 KB
/
legacy.routes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { LegacyRouteHelper } from './legacy.route-helper';
import { legacyApp } from '../legacy.app.module';
import { routeHelper } from 'src/app/routing/route-helper';
legacyApp.config(legacyRoutes);
legacyRoutes.$inject = ['$stateProvider', '$urlRouterProvider'];
function legacyRoutes($stateProvider, $urlRouterProvider) {
$stateProvider
.state('helloAjs', {
url: '/hello-ajs',
template: `
<div class="comp ajs">
<h3>Hello from AngularJs Route</h3>
<a href="/hello-ng">Hello Ng</a>
</div>
`,
});
$urlRouterProvider.otherwise(($injector, $location) => {
// If it's a valid Angular Route, Angular will handle it.
if (routeHelper.isValidRoute($location.path())) {
const legacyRouteHelper: LegacyRouteHelper = $injector.get('legacyRouteHelper');
return legacyRouteHelper.handleNgRoute();
}
// If it's not a valid route in Angular (or AngularJs cause we're in the $otherwise fn),
// redirect to our default page
$location.path('/hello-ng');
});
}