• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

54
Views
Angular2 ng-template documentation and usage

I updated my project to the latest angular2 4.0.0-rc.5 and upon building it spits a lot of warnings like this:

Template parse warnings:
The <template> element is deprecated. Use <ng-template> instead ("_newGroupReward.group.description}}

My question is - what is and where can I find info about it and how to use it ? I have been googling however the only doc I could find is about the stable 2.4.x versions ( official docs ).

Best regards

2 months ago ·

Santiago Trujillo

2 answers
Answer question

0

ngTemplate is a replacement for template, It is used when a sample template should be injected into the DOM.

The below example is illustrated with using ngIf else as below,

<ng-template #loading>Failed to do something wrong...</ng-template>
<div *ngIf="userObservable;else loading;">
  Aravind is here
</div>

When I am using loading, angular calls the TemplateRef with the name as loading denoted by #loading and respective template is replaced inside the div.

LIVE DEMO

Documentation link

2 months ago · Santiago Trujillo Report

0

I found this reference. It may be helpful.

https://toddmotto.com/angular-ngfor-template-element

Update:

I was having the same issue. I fixed it by replacing the ng-template with ng-container . Take a look to the official docs for more details.

2 months ago · Santiago Trujillo Report
Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.