From 84aec02adae5c93567c12f4a92ca7d0b969dbf7d Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sat, 17 Jun 2017 11:30:34 -0700 Subject: [PATCH] feat(view): Support shorthand for named views, `views: { viewName: Component }` Closes https://github.com/ui-router/angular/issues/19 --- src/statebuilders/views.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/statebuilders/views.ts b/src/statebuilders/views.ts index 6728c9ec1..d94d4b83a 100644 --- a/src/statebuilders/views.ts +++ b/src/statebuilders/views.ts @@ -1,5 +1,5 @@ /** @module ng2 */ /** */ -import {StateObject} from "@uirouter/core"; +import { isFunction, StateObject } from "@uirouter/core"; import {PathNode} from "@uirouter/core"; import {pick, forEach} from "@uirouter/core"; import {ViewConfig} from "@uirouter/core"; @@ -22,6 +22,7 @@ export function ng2ViewsBuilder(state: StateObject) { forEach(viewsObject, function (config: Ng2ViewDeclaration, name: string) { name = name || "$default"; // Account for views: { "": { template... } } + if (isFunction(config)) config = { component: config as any }; if (Object.keys(config).length == 0) return; config.$type = "ng2";