* 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
)
| 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. |
no test coverage detected