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
9
votes
2 answers

How to use createEmbeddedView method of TemplateRef in angular4?

I am starting to learn DOM manipulation in Angular and notice templateRef and its method createEmbeddedView. I am more curious to learn about this method. Now all my question is, how to use the createEmbeddedView of this method @Component({ …
Lijin Durairaj
  • 4,910
  • 15
  • 52
  • 85
9
votes
3 answers

Angular2, evaluate template from string inside a component

It's possible evaluate template from string in a variable?. I need place the string in the component instead of the expression, e.g. template: "
{{ template_string }}
" template_string contains: {{ name }} and all should be…
rafrsr
  • 1,940
  • 3
  • 15
  • 31
8
votes
1 answer

How is cdkPortal different from ngTemplateOutlet

Why should one use cdkPortal over the built-in directives ngTemplateOutlet and ngComponentOutlet in Angular. aren't both of them provide the same functionality? Are there specific features in the CDK Portal that doesn't come with the built-in…
Murhaf Sousli
  • 12,622
  • 20
  • 119
  • 185
8
votes
1 answer

VS Code: How to refactor(rename variable) in an Angular template file?

I want to rename a variable used across an angular template file (i.e. an xxx.component.html file). This could be done with Shift + F6 shortcut in WebStorm. How to do it in vscode? F2 doesn't help.
djy
  • 737
  • 6
  • 14
8
votes
2 answers

How do I select a ContentChild of a native element in Angular 6?

I have a component that uses content projection. I want to do something like this in my component: @ContentChild('button') button: ElementRef; However, when I check this.button, it is undefined both in…
Yulian
  • 6,262
  • 10
  • 65
  • 92
8
votes
4 answers

Angular html file not found in component library

I'm building a component library for angular which we will share across projects. But when i build the package the html files don't get copied to the dist folder. I get the error angular Failed to load text-input.component.html. This is my…
Sjoerd de Wit
  • 2,353
  • 5
  • 26
  • 45
8
votes
2 answers

Is there a way to get the HTML template for an Angular* component?

I'm trying to create a library of shared Angular components to use across a number of different web projects. Along with the shared component library, I'm trying to create a web project that contains and displays all of those components and code…
peinearydevelopment
  • 11,042
  • 5
  • 48
  • 76
8
votes
1 answer

Access template variable in *ngIf

I am trying to define a template variable on an element and use its hidden attribute to identify whether the element is actually present in the DOM and then display another element based on that. But if there is a structural directive, template…
TechCrunch
  • 2,924
  • 5
  • 45
  • 79
8
votes
2 answers

Angular 4 template error: 'anonymous' does not contain such a member

Angular 4 written in Typescript 2.3.4 component.ts /** * Info that drives the tabs in the template. Array is filled * in ngOnInit() once data is received from the server */ public tabs:Array<{ title:string, description:string, …
BeetleJuice
  • 39,516
  • 19
  • 105
  • 165
8
votes
2 answers

Can I Create Nested Angular Component HTML Selectors?

Updated: Per Thierry Templier's response: Below is essentially what I want to do, but unfortunately the inner components aren't rendering. Is there a way to nest components via their HTML selectors like so?
SnoopDougg
  • 1,467
  • 2
  • 19
  • 35
8
votes
2 answers

Update cached templates

I make use of templateUrl and it works great! app.directive('myDir', function() { return { templateUrl: 'partials/directives/template.html' }; }; However... when I make changes to these templates it doesn't update. In development…
7
votes
2 answers

Angular Material - how to set mat-horizontal-content-container padding 0

Im using angular material stepper. I need set padding 0 on mobile view.On developer console i could set padding 0 by changing .mat-horizontal-content-container. But its not working when i add .mat-horizontal-content-container{padding:0…
7
votes
4 answers

Create an Angular component to display a set of html table cells to embed in other tables

I have a lot of html tables that share the same 15 columns along with custom columns that are specific for each table. I would like to create these common 15 columns as a component that takes in a set of data and shows up as the 15 td's without a…
Jeremy
  • 1,023
  • 3
  • 18
  • 33
7
votes
1 answer

Angular 2 dynamically change the template in the ngTemplateOutlet

I want to dynamically change the template in the ngTemplateOutlet. The ngTemplateOutlet would change when the selectedTab changes. I have two basic templates below called #Tab1 and #Tab2. Note: I'm using angular version 4. Tab Menu Example…
AngularM
  • 15,982
  • 28
  • 94
  • 169
7
votes
2 answers

How to handle template errors (and other errors) in angular 2?

When ever there is a template error in angular 2, the entire application fails to work. Shouldn't only the component that had the template that caused the error, fail to work and the rest of the application be working fine? How to handle errors so…
harryjohn
  • 656
  • 1
  • 8
  • 25