Skip to content

Commit 84aec02

Browse files
feat(view): Support shorthand for named views, views: { viewName: Component }
Closes #19
1 parent faa9bcf commit 84aec02

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/statebuilders/views.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @module ng2 */ /** */
2-
import {StateObject} from "@uirouter/core";
2+
import { isFunction, StateObject } from "@uirouter/core";
33
import {PathNode} from "@uirouter/core";
44
import {pick, forEach} from "@uirouter/core";
55
import {ViewConfig} from "@uirouter/core";
@@ -22,6 +22,7 @@ export function ng2ViewsBuilder(state: StateObject) {
2222

2323
forEach(viewsObject, function (config: Ng2ViewDeclaration, name: string) {
2424
name = name || "$default"; // Account for views: { "": { template... } }
25+
if (isFunction(config)) config = { component: config as any };
2526
if (Object.keys(config).length == 0) return;
2627

2728
config.$type = "ng2";

0 commit comments

Comments
 (0)