0

I have created the text input field as component. Now i am using the component in a form multiple times. I want to apply a directive only to selected fields. I want to pass the directive name as the @input to component and pass it to component html template as attribute dynamically.

Psuedo code

<form> 

    <text-input-comp [directiveName]="mydirective" ></text-input-comp>
    <text-input-comp></text-input-comp>
    <text-input-comp></text-input-comp>

</form>

Any help will be appreciated. Thanks

yogesh
  • 29
  • 1
  • 3
  • To apply directive to any element, you just need to call it as . I don't understand why you need to input for directive name? – Jayakrishnan May 27 '17 at 04:52
  • is my component selector name. my component looks like @Component({ selector: 'aps-text-field', templateUrl: './text-field.component.html', styleUrls: ['./text-field.component.scss'] }) . In text-field.component.html file has the actual html input field code. I want to apply directive to that html input field. @JayakrishnanGounder – yogesh May 27 '17 at 20:05
  • Then apply directive to that input field directly. Share the html template for text-input-comp to help you – Jayakrishnan May 28 '17 at 06:07

0 Answers0