MCPcopy
hub / github.com/angular-ui/ui-router / fromConfig

Method fromConfig

src/templateFactory.ts:60–81  ·  view source on GitHub ↗

* Creates a template from a configuration object. * * @param config Configuration object for which to load a template. * The following properties are search in the specified order, and the first one * that is defined is used to create the template: * * @param params Parameters to

(
    config: Ng1ViewDeclaration,
    params: any,
    context: ResolveContext
  )

Source from the content-addressed store, hash-verified

58 * that string,or `null` if no template is configured.
59 */
60 fromConfig(
61 config: Ng1ViewDeclaration,
62 params: any,
63 context: ResolveContext
64 ): Promise<{ template?: string; component?: string }> {
65 const defaultTemplate = '<ui-view></ui-view>';
66
67 const asTemplate = (result) => services.$q.when(result).then((str) => ({ template: str }));
68 const asComponent = (result) => services.$q.when(result).then((str) => ({ component: str }));
69
70 return isDefined(config.template)
71 ? asTemplate(this.fromString(config.template, params))
72 : isDefined(config.templateUrl)
73 ? asTemplate(this.fromUrl(config.templateUrl, params))
74 : isDefined(config.templateProvider)
75 ? asTemplate(this.fromProvider(config.templateProvider, params, context))
76 : isDefined(config.component)
77 ? asComponent(config.component)
78 : isDefined(config.componentProvider)
79 ? asComponent(this.fromComponentProvider(config.componentProvider, params, context))
80 : asTemplate(defaultTemplate);
81 }
82
83 /**
84 * Creates a template from a string or a function returning a string.

Callers 1

loadMethod · 0.80

Calls 5

fromStringMethod · 0.95
fromUrlMethod · 0.95
fromProviderMethod · 0.95
fromComponentProviderMethod · 0.95
isDefinedFunction · 0.50

Tested by

no test coverage detected