Questions tagged [angular-template]

Use this tag for Angular questions which are related to templates topics, such as interpolation ({{...}}), template expressions, template statements, data-binding...

The Angular application manages what the user sees and can do, achieving this through the interaction of a component class instance (the component) and its user-facing template.

In Angular, the component plays the part of the controller/viewmodel, and the template represents the view.

To find more information :

674 questions
1161
votes
24 answers

Angular: conditional class with *ngClass

What is wrong with my Angular code? I am getting the following error: Cannot read property 'remove' of undefined at BrowserDomAdapter.removeClass
  1. Step1
  2. daniel
    • 34,281
    • 39
    • 104
    • 158
974
votes
22 answers

How can I use "*ngIf else"?

I'm using Angular and I want to use *ngIf else (available since version 4) in this example:
content here ...
other content here...
How can I achieve the same behavior with ngIf else?
El houcine bougarfaoui
  • 35,805
  • 9
  • 37
  • 37
737
votes
23 answers

What is the equivalent of ngShow and ngHide in Angular 2+?

I have a number of elements that I want to be visible under certain conditions. In AngularJS I would write
stuff
How can I do this in Angular 2+?
Mihai Răducanu
  • 12,225
  • 4
  • 22
  • 31
241
votes
3 answers

Dynamic tabs with user-click chosen components

I'm trying to setup a tab system that allows for components to register themselves (with a title). The first tab is like an inbox, there's plenty of actions/link items to choose from for the users, and each of these clicks should be able to…
Cuel
  • 2,620
  • 3
  • 13
  • 13
220
votes
7 answers

How and where to use ::ng-deep?

How and where can one use ::ng-deep in Angular 4? Actually I want to overwrite some of the CSS properties of the child components from the parent components. Moreover is it supported on IE11?
Jeyabalan Thavamani
  • 3,057
  • 8
  • 21
  • 33
143
votes
3 answers

Dynamic template reference variable inside ngFor (Angular 9)

How to declare a dynamic template reference variable inside a ngFor element? I want to use the popover component from ng-bootstrap, the popover code (with Html binding) is as shown: Hello,…
Boo Yan Jiong
  • 2,491
  • 5
  • 17
  • 31
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
119
votes
4 answers

How to apply multiple template bindings on one element in angular

I'm using template like following:
96
votes
2 answers

What does two colons inside an angular expression {{::}} mean?

What is the difference between: {{::office.name}} and {{office.name}} in angularJS?
J0B
  • 1,648
  • 1
  • 12
  • 24
92
votes
4 answers

Best method to set different layout for different pages in angular 4

I am new to angular 4. What I'm trying to achieve is to set different layout headers and footers for different pages in my app. I have three different cases: Login, register page (no header, no footer) routes: ['login','register'] Marketing site…
ninja dev
  • 1,687
  • 2
  • 12
  • 12
92
votes
21 answers

Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays

I looked at similar questions, but none of them helped me. I am going to receive an object like the following: [ { "id": 1, "name": "Safa", "email": "neerupeeru@mail.ee", "purpose": "thesis", "programme": "Software…
Jeff
  • 7,767
  • 28
  • 85
  • 138
91
votes
2 answers

Angular 5 adds 'ng-star-inserted' in some classes - what is that?

I'm seeing that among the classes added to an element, sometimes there's this 'ng-star-inserted' added as well and I'd like to know more as to why is it there?
vzR
  • 1,377
  • 1
  • 12
  • 16
87
votes
3 answers

Get reference to a directive used in a component

I have a component whose template looks something like this:
Some content here
I need access to the MyCustomDirective class instance used here. When I want to get access to a child component, I use a ViewChild…
Ben Dilts
  • 10,535
  • 16
  • 54
  • 85
62
votes
3 answers

Getting reference to child component in parent component

In Angular 2, I have a component that has a child component. However, I want to acquire a copy of that child component to use in the parent, to call its functions or whatever. I found out that I could use local variables, and that way I will be able…
AbdulRahman AlHamali
  • 1,851
  • 1
  • 14
  • 18
48
votes
3 answers

How to make a if-else Angular template with only ng-container?

I would like to make an if-else statement in my angular template. I started with that : [... HERE IS A RESULT 1] [... HERE IS A RESULT…
Thomas Betous
  • 4,633
  • 2
  • 24
  • 45
1
2 3
44 45