Skip to content

Commit

Permalink
support named views
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Jul 12, 2016
1 parent 98f0b83 commit a2ce4a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<a name="1.0.8"></a>
# 1.0.8 (2016-07-11)

Support named views

<a name="1.0.7"></a>
# 1.0.7 (2016-07-09)

Expand Down
8 changes: 5 additions & 3 deletions ng1-to-ng2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as angular from "angular";
import {provide, ElementRef, Component, Inject, ComponentMetadata} from "@angular/core";
import {provide, ElementRef, Component, Input, Inject, ComponentMetadata} from "@angular/core";
import {UpgradeAdapter} from "@angular/upgrade";

import { Ng1ViewConfig, StateProvider, State } from "angular-ui-router";
Expand All @@ -16,7 +16,7 @@ declare var Reflect: any;

@Component({
selector: 'ui-view-ng-upgrade',
template: `<ui-view></ui-view>`,
template: `<ui-view [name]="name"></ui-view>`,
directives: [UIROUTER_DIRECTIVES],
viewProviders: [ provide(UIView.PARENT_INJECT, {useValue: { } }) ],
})
Expand All @@ -27,6 +27,8 @@ declare var Reflect: any;
* up the DOM and grabbing the .data('$uiView') that the ng1 ui-view directive provided.
*/
class UIViewNgUpgrade {
@Input() private name: string;

constructor(ref: ElementRef, @Inject(UIView.PARENT_INJECT) parent: ParentUIViewInject, registry: StateRegistry) {
// From the ui-view-ng-upgrade component's element ref, walk up the DOM two elements...
// There will first be one ng1 ui-view which hosts this element, and then that ui-view's
Expand Down Expand Up @@ -106,7 +108,7 @@ upgradeModule.config([ '$stateProvider', ($stateProvider: StateProvider) => {
// with a <ui-view-ng-upgrade> adapter directive template
viewDecl.$type = "ng1-to-ng2";
viewDecl.templateProvider = null;
viewDecl.template = "<ui-view-ng-upgrade></ui-view-ng-upgrade>";
viewDecl.template = "<ui-view-ng-upgrade name='" + viewDecl.$uiViewName + "'></ui-view-ng-upgrade>";
}
});
return views;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui-router-ng1-to-ng2",
"version": "1.0.7",
"version": "1.0.8",
"scripts": {
"build": "npm run clean && npm run tsc",
"clean": "rm -f *.d.ts *.js *.js.map",
Expand Down

0 comments on commit a2ce4a8

Please sign in to comment.