-1

I have function which is gets template for my component. Here it is:

/**
* 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 "";
  }
}

And in component I use this function:

import { getTemplate } from "../../services/helpertools";


@Component({
  template: getTemplate('pages/tabs/tabs')
})

But occurs a error:

 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

How to solve it?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Alexander Zakusilo
  • 1,466
  • 3
  • 16
  • 34

1 Answers1

0

The problem in returned content, not in the way you do it. I tried the same way, but return static content like this

export function getTemplate()
{
    return '<h1>test</h1>';
}

@Component({
    selector: 'firm-questions',
    template: getTemplate()
})

It works fine. So, please check and post content you are getting from this function

Victor Bredihin
  • 2,220
  • 21
  • 30
  • No. The reason is in that I can't use function to return template. May be you know how to solve it? – Alexander Zakusilo Apr 12 '17 at 15:41
  • I'm afraid it's not about angular problem. Here is an example https://plnkr.co/edit/JBTerWpLxTFlsC8ioow7?p=preview – Victor Bredihin Apr 12 '17 at 15:50
  • Yes I do. I use Ionic 2 app. And when I use command 'ionic run android'. All works fine, but when I use command 'ionic run android --prod'. It's try to compile for production, and when gets a error. – Alexander Zakusilo Apr 12 '17 at 15:51
  • I use "@angular/common": "4.0.1", "@angular/compiler": "4.0.1", "@angular/compiler-cli": "4.0.1", "@angular/core": "4.0.1", "@angular/forms": "4.0.1", "@angular/http": "4.0.1", "@angular/platform-browser": "4.0.1", "@angular/platform-browser-dynamic": "4.0.1", "@angular/platform-server": "4.0.1", – Alexander Zakusilo Apr 12 '17 at 15:53
  • maybe it's cache problem? The only real difference between run and run -- prod is cache – Victor Bredihin Apr 12 '17 at 15:56
  • http://stackoverflow.com/questions/28676631/is-it-possible-to-clear-the-view-cache-in-ionic – Victor Bredihin Apr 12 '17 at 16:01