feat(router): add reuse support for angular 1.x router

Closes #3698
This commit is contained in:
Shahar Talmi
2015-08-18 01:31:41 +03:00
committed by Brian Ford
parent fde026a9e4
commit ddb62feae6
3 changed files with 89 additions and 5 deletions

View File

@ -1,3 +1,5 @@
'use strict';
var fs = require('fs');
var ts = require('typescript');
@ -58,6 +60,10 @@ function main() {
"});",
"}));",
"}",
"if (constructor.$routeConfig) {",
"constructor.annotations = constructor.annotations || [];",
"constructor.annotations.push(new angular.annotations.RouteConfig(constructor.$routeConfig));",
"}",
"if (constructor.annotations) {",
"constructor.annotations.forEach(function(annotation) {",
"if (annotation instanceof RouteConfig) {",
@ -70,7 +76,11 @@ function main() {
"});",
"var router = new RootRouter(registry, undefined, location, new Object());",
"$rootScope.$watch(function () { return $location.path(); }, function (path) { router.navigate(path); });",
"$rootScope.$watch(function () { return $location.path(); }, function (path) {",
"if (router.lastNavigationAttempt !== path) {",
"router.navigate(path);",
"}",
"});",
"return router;"
].join('\n'));