Skip to content

Commit

Permalink
feat(view): Support shorthand for named views, `views: { viewName: Co…
Browse files Browse the repository at this point in the history
…mponent }`

Closes #19
  • Loading branch information
christopherthielen committed Jun 17, 2017
1 parent faa9bcf commit 84aec02
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/statebuilders/views.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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";
Expand Down

0 comments on commit 84aec02

Please sign in to comment.