Use for questions about Angular 2+ directives
Questions tagged [angular2-directives]
1806 questions
11
votes
2 answers
Add a component dynamically to a child element using a directive
Trying to place a component dynamically to a child element, using a directive.
The component (as template):
@Component({
selector: 'ps-tooltip',
template: `
…

Paulo Soares
- 145
- 1
- 7
11
votes
1 answer
Angular 2: focusing input causes 'expression has changed after it was changed' error
In my Angular 2 application, I want to have a list of inputs. Pressing Enter inside one of them would add a new input and immediately focus on it. This is a question that has already been asked on this site and Eric Martinez provided a neat answer…

kamilk
- 3,829
- 1
- 27
- 40
11
votes
4 answers
Can the ViewChildren Decorator in Angular2 work with Interfaces?
The way I understand Angular 2, the ViewChildren decorator allows a Component to get a Query for other Components or Directives. I can get this to work in Typescript when I know the specific Type of the Component, but I would like to be able to get…

brianv
- 143
- 1
- 7
11
votes
3 answers
How to dynamically bind the value of a checkbox Angular 2
Hi all: I have a component. The component view has a table:
Recipients List
Id | Name | …
Inside the directive, I have HostBindings for adding classes based on the event and HostListeners for listening for mouseenter and mouseleave events. For example:…
![]()
Lee
10
votes
4 answers
How to add some html elements using Angular2's attribute directiveIf a certain attribute directive is present on an HMTL element, I would like to show some additional html content. I have searched but can't find what am looking for. For example if P tag has a directive called can-delete, then I would like delete…
![]()
user1275105
10
votes
3 answers
Change an input's ngModel value using a directive Angular 2I'm stuck on how to access and change an inputs ngModel value using a directive. The outcome of the issue is that the model's address value doesn't update when I select the desired address...it's just set to what I actually typed into the input,…
![]()
sharpmachine
10
votes
3 answers
How to send a value from one component to another?I make a componenet in which I have one input field and button.On click of button I am diplaying the second component.I want to send data from one component to another component ?
how I will send data from one component to another ..I need to send…
![]()
user944513
9
votes
1 answer
Selector in DirectivesThe following directive should hide an element.
import {Directive, ElementRef, Input, Renderer2} from '@angular/core';
import {el} from "@angular/platform-browser/testing/src/browser_util";
// Directive decorator
@Directive({ selector: '[hide-me]'…
![]()
Manu Chadha
|
---|