We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

NodeTemplate throws: ERROR TypeError: str.replace is not a function at evalExp (vendor.js:108640) ...


I´m trying to use  template in angular treeview following the next demo: https://ej2.syncfusion.com/angular/documentation/treeview/template .
The issue is that for the moment that render the treeview without template it renders ok but when I add <ng-template  nodeTemplate="" let-data="">... the chrome console throws the next lines: 
ERROR TypeError: str.replace is not a function
    at evalExp (vendor.js:108640)
    at compile (vendor.js:108625)
    at Object.push../node_modules/@syncfusion/ej2-angular-navigations/node_modules/@syncfusion/ej2-base/src/template-engine.js.Engine.compile (vendor.js:108554)
    at compile (vendor.js:108513)
    at TreeViewComponent.push../node_modules/@syncfusion/ej2-angular-navigations/node_modules/@syncfusion/ej2-navigations/src/treeview/treeview.js.TreeView.templateComplier (vendor.js:139371)
    at TreeViewComponent.push../node_modules/@syncfusion/ej2-angular-navigations/node_modules/@syncfusion/ej2-navigations/src/treeview/treeview.js.TreeView.initialize (vendor.js:139332)
    at TreeViewComponent.push../node_modules/@syncfusion/ej2-angular-navigations/node_modules/@syncfusion/ej2-navigations/src/treeview/treeview.js.TreeView.render (vendor.js:139316)
    at TreeViewComponent.push../node_modules/@syncfusion/ej2-angular-navigations/node_modules/@syncfusion/ej2-base/src/component.js.Component.appendTo (vendor.js:103183)
    at vendor.js:100559
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:2766)

Do you have any solution to this issue?

5 Replies

CI Christopher Issac Sunder K Syncfusion Team November 27, 2018 07:37 AM UTC

Hi Jon Andoni, 

Thank you for contacting Syncfusion support. 

We have checked your reported problem at our end. We suspect that the template content is initialized improperly in ng template. Could you please ensure the ng template content in TreeView? 

<ejs-treeview id="tree" [fields]="field" [cssClass]="cssClass"> 
      <!-- Template to render tree node --> 
       <ng-template #nodeTemplate="" let-data=""> 
       <img class="eimage" src="https://ej2.syncfusion.com/demos/src/treeview/images/employees/{{data.eimg}}.png" alt="{{data.eimg}}"/> 
            <div class="ename">{{data.name}}</div> 
            <div class="ejob">{{data.job}}</div> 

Please share the template content with tree view and its bounded data source if you are still facing the sample problem. 


JA Jon Andoni November 27, 2018 12:54 PM UTC

Hello Christo,

This is the template content:

<ejs-treeview #tree [fields]='field' (nodeClicked)="onNodeClick($event)" [cssClass]='cssClass'>
<ng-template #nodeTemplate="" let-data="">

It´s seems to be good.

Fields charge a javascript array object that contains properties like text, id etc, but it doens´t matter because in this example i´m not binding any data. This same example in stackblitz works fine, test it.

CI Christopher Issac Sunder K Syncfusion Team November 28, 2018 07:35 AM UTC

Hi Jon Andoni, 

Thanks for the update. 

We tried hard to reproduce your reported problem at our end. But ng-template concepts works fine for our TreeView component. As per your scenario, we have checked your problem on both stackblitz application and local angular-cli application, but we were unable to reproduce it. Could you please check the samples? 

Local Angular CLI application:  

You can use the below command to install the npm packages and run it. 

  1. npm install
  2. ng serve

Still you are facing the same issue, Could you please share the below information? 

  1. Syncfusion angular navigations package version
  2. Which way you have used our angular navigations’ TreeView component in your application(Angular-cli, webpack, etc…)
  3. If possible, please try to reproduce the issue with the provided sample or send us other any sample which reproduces the issue.


JA Jon Andoni November 28, 2018 01:16 PM UTC

Hello Christo,

Thanks for example in stackblitz and on angular-cli project.

Finally, the error was that with npm i @syncfusion/ej2-angular-navigations I installed the 16.6.30 version and ng-template doesn´t work with this version. So I update to the 16.6.34 version and it works.

Thank you.

CI Christopher Issac Sunder K Syncfusion Team November 29, 2018 06:01 AM UTC

Hi Jon Andoni, 

We are glad to hear that the issue has been resolved at your end. Please let us know if you need any further assistance. 


Live Chat Icon For mobile
Up arrow icon