【发布时间】:2017-04-12 23:14:06
【问题描述】:
我有一个为我的组件获取模板的函数。这里是:
/**
* Return template from template's cache
*
* @param url_path - way to needed template
*/
export function getTemplate(url_path)
{
if (window['app_templates'][url_path]){
return window['app_templates'][url_path];
}else{
console.error('Failed to load template by path ' + url_path);
return "";
}
}
在组件中我使用了这个函数:
import { getTemplate } from "../../services/helpertools";
@Component({
template: getTemplate('pages/tabs/tabs')
})
但是出现错误:
Error: Error encountered resolving symbol values statically. Calling
function 'getTemplate', function calls
are not supported. Consider replacing the function or lambda with a
reference to an exported function,
resolving symbol TabsPage in
D:/denwerready/-readyscript/modules/mobilesiteapp/appsource/src/page
s/tabs/tabspage.ts, resolving symbol
TabsPage in D:/denwerready/-readyscript/modules/mobilesiteapp/appsou
rce/src/pages/tabs/tabspage.ts
Error: Error encountered resolving symbol values statically. Calling function 'g
etTemplate', function calls are not supported. Consider replacing the function o
r lambda with a reference to an exported function, resolving symbol TabsPage in
如何解决?
【问题讨论】:
标签: angular templates ionic2 static-methods