diff --git a/ng1-to-ng2.ts b/ng1-to-ng2.ts index e45bc7e9..4f7049a8 100644 --- a/ng1-to-ng2.ts +++ b/ng1-to-ng2.ts @@ -1,11 +1,12 @@ import * as angular from "angular"; import {provide, ElementRef, Component, Inject, ComponentMetadata} from "angular2/core"; import { - UiView, UIRouter, TransitionService, StateService, UIRouterGlobals, UIROUTER_DIRECTIVES, forEach, - UrlRouter, ViewService, StateRegistry, UrlMatcherFactory + UiView, UIRouter, TransitionService, StateService, UIRouterGlobals, UIROUTER_DIRECTIVES, forEach, extend, + UrlRouter, ViewService, StateRegistry, UrlMatcherFactory, Ng2ViewDeclaration, Ng2ViewConfig, Node } from "ui-router-ng2"; import {CORE_DIRECTIVES} from "angular2/common"; import {UpgradeAdapter} from "angular2/upgrade"; +import {Ng1ViewConfig} from "angular-ui-router"; export let upgradeModule = angular.module('ui.router.upgrade', ['ui.router']); @@ -93,6 +94,7 @@ upgradeModule.config([ '$stateProvider', $stateProvider => { // Update the view config. // Override default ng1 `component:` behavior (of defining a templateProvider) // with a adapter directive template + viewDecl.$type = "ng1-to-ng2"; viewDecl.templateProvider = null; viewDecl.template = ""; } @@ -101,3 +103,13 @@ upgradeModule.config([ '$stateProvider', $stateProvider => { }) }]); +upgradeModule.run([ '$view', $view => { + $view.viewConfigFactory('ng2', (node: Node, config: Ng2ViewDeclaration) => new Ng2ViewConfig(node, config)); + + $view.viewConfigFactory('ng1-to-ng2', (node: Node, config: Ng2ViewDeclaration) => { + var ng1ViewConfig = new Ng1ViewConfig( node, Object.assign({}, config, { $type: 'ng1'})); + var ng2ViewConfig = new Ng2ViewConfig( node, Object.assign({}, config, { $type: 'ng2'})); + + return [ ng2ViewConfig, ng1ViewConfig ]; + }); +}]); diff --git a/package.json b/package.json index bdc6f6ca..c81762a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ui-router-ng1-to-ng2", - "version": "1.0.3", + "version": "1.0.4", "scripts": { "build": "npm run clean && npm run tsc", "clean": "rm -f *.d.ts *.js *.js.map", @@ -11,13 +11,13 @@ "peerDependencies": { "angular": "^1.5.0", "angular2": "^2.0.0-beta.13", - "angular-ui-router": "^1.0.0-alpha.4", + "angular-ui-router": "^1.0.0-alpha.5", "ui-router-ng2": "^1.0.0-alpha.4" }, "devDependencies": { "angular": "1.5.3", "angular2": "2.0.0-beta.13", - "angular-ui-router": "^1.0.0-alpha.4", + "angular-ui-router": "1.0.0-alpha.5", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.2",