Questions tagged [angular2-template]

For questions referencing Angular Template Syntax including: interpolation, input(property) bindings, output(event) bindings, two-way binding, local variables, star syntax, etc. This tag is specific to angular version 2.x and above

Tag content based loosely off Victor Savkin's Angular Template Syntax article

2856 questions
956
votes
23 answers

Angular HTML binding

I am writing an Angular application and I have an HTML response I want to display. How do I do that? If I simply use the binding syntax {{myVal}} it encodes all HTML characters (of course). I need somehow to bind the innerHTML of a div to the…
Aviad P.
  • 28,132
  • 10
  • 97
  • 112
366
votes
27 answers

Angular 2 Scroll to top on Route Change

In my Angular 2 app when I scroll down a page and click the link at the bottom of the page, it does change the route and takes me to the next page but it doesn't scroll to the top of the page. As a result, if the first page is lengthy and 2nd page…
293
votes
2 answers

No provider for TemplateRef! (NgIf ->TemplateRef)

I'm trying to show a checkmark if an answer is the accepted answer: template: `
` But I get this error: EXCEPTION: No provider for TemplateRef! (NgIf ->TemplateRef) What am I doing wrong?
Mark Rajcok
  • 348,511
  • 112
  • 482
  • 482
262
votes
2 answers

How can I write data attributes using Angular?

When I try to use a data attribute in my template, like this:
  1. {{ section.text }}
Angular 2 crashes with: EXCEPTION: Template parse…
Serj Sagan
  • 24,625
  • 17
  • 133
  • 166
221
votes
7 answers

How to add "class" to host element?

I dont't know how to add to my component a dynamic class attribute but inside the template html (component.html). The only solution I found is to modify the item via "ElementRef" native element. That solution seems a little…
lascarayf
  • 2,622
  • 2
  • 16
  • 17
183
votes
14 answers

Angular 2: Can't bind to 'ngModel' since it isn't a known property of 'input'

I'm trying to implement Dynamic Forms in Angular 2. I've added additional functionalities like Delete and Cancel to the dynamic forms. I've followed this documentation: https://angular.io/docs/ts/latest/cookbook/dynamic-form.html I've made some…
Varun
  • 3,355
  • 4
  • 18
  • 33
181
votes
28 answers

Can't bind to 'ngForOf' since it isn't a known property of 'tr' (final release)

I'm using Angular2 2.1.0. When I want to display a list of companies, I got this error. in file.component.ts : public companies: any[] = [ { "id": 0, "name": "Available" }, { "id": 1, "name": "Ready" }, { "id": 2, "name": "Started"…
Mourad Idrissi
  • 2,655
  • 5
  • 14
  • 27
179
votes
2 answers

What is let-* in Angular 2 templates?

I came across a strange assignment syntax inside an Angular 2 template. It appears that let-col and…
Steven Liekens
  • 10,761
  • 4
  • 50
  • 77
167
votes
5 answers