Scipion
Scipion

Reputation: 11888

Angular2 Declaring a directive's selector to require a text input

I have just created a number directive :

@Directive({
  selector: '[ngModel][number]'
})
export class NumberDirective  {...}

I would like my selector to be even more specific and requires a text input :

<input type="text" [(ngModel)]="..." [number]="...">

Upvotes: 1

Views: 488

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657721

You can use attribute selectors with value

selector: 'input[type="text"][ngModel][number]'

See also https://developer.mozilla.org/en/docs/Web/CSS/Attribute_selectors

Upvotes: 2

Related Questions