Questions tagged [ng-template]
329 questions
130
votes
2 answers
Angular - ng-template with parameter inside ngIf inside ngFor
I am trying to build this template:
...
{{…

yanivps
- 1,993
- 3
- 25
- 33
82
votes
1 answer
why *ngIf doesnt'work with ng-template?
I have a condition in the template as follows:
Section {{seat?.section}} , …
user7426734
74
votes
4 answers
What is $implicit in angular 2?
How is the following keyword used in angular2 ng-templates
What is the purpose of $implicit in angular 2 templates?
What is relationship between let- and $implicit?

Mantu Nigam
- 3,690
- 7
- 24
- 41
45
votes
4 answers
What are practical scenarios of *ngTemplateOutlet directive?
I was reading about *ngTemplateOutlet directive. The use of this directive is to instantiate a template dynamically by a template reference and context object as parameters.
What I want to know is that we have so many things in Angular to achieve…

patrick.1729
- 4,222
- 2
- 20
- 29
32
votes
2 answers
How to include an ng-template element without a condition in Angular 2
I need an HTML fragment more than once in my Angular template. Instead of writing the HTML code multiple times, I decided to put it inside an ng-template element and use that element replicated in the code.
For example:
…

user7346048
- 798
- 1
- 9
- 15
30
votes
5 answers
Passing ngFor variable to an ngIf template
How do I pass the current variable in an ngFor loop to ngIf, if it is using templates with then/else syntax?
It appears that they pass through fine when used inline, but aren't accessible from a template, for example:
- 10,388
- 3
- 23
- 41

match
22
votes
5 answers
angular2 ng-template in a separate file
angular2 how to use ng-template from a different file? When I place the ng-template within the same HTML where I use it works but when I move ng-template into a separate file then it won't work. Is there a way to move ng-template into its own file…

Pratap A.K
- 4,337
- 11
- 42
- 79
21
votes
2 answers
Open ng-bootstrap modal programmatically
I've got an angular 4 page including a ng-bootstrap modal. My code looks like this.
foo.html
[...]
…

Christian Riese
- 594
- 1
- 5
- 18
18
votes
4 answers
How to load the ng-template in separate file?
In below sample, I have used ng-template like below and it is working fine.
Sample link: click here
…

Kumaresan Sd
- 1,399
- 4
- 16
- 34
15
votes
2 answers
Angular pass a Component as ng-template of another Component
In my Angular 6 app I need to pass a Component to another Component as its ng-template.
The reason is that I have a Component A that I need to replicate many times, but each time it has to include different components (let's call them Component B…

Francesco Borzi
- 56,083
- 47
- 179
- 252
15
votes
1 answer
How to style angular ng-template selector
I am struggling with styling ng-template tag.
what i have tried in my .css file until now:
using #other_content as ID in my .css file
adding a class to
styling all tags
It's not working and after searching i have not found any…

Jonathan Applebaum
- 5,738
- 4
- 33
- 52
14
votes
2 answers
Template reference variable returns undefined inside ng-template
Already tried this and this solution but nothing worked.
I am using Angular 7 and trying to get a reference variable which I've placed inside the ng-template tag. But it always returns undefined
test-component.html
…

Adnan Sheikh
- 760
- 3
- 13
- 27
12
votes
3 answers
Function inside a template is called many times (Angular JS)
Today I had to fix a performance issue caused by this code: Pay attention to updateStats called inside the template