angular - Angular2 Directive - selector with multiple ids -
i'm implementing custom directive in angular 2, directive form validation, , in many places see in directive definition selector property associated multiple ids - example:
@directive({ selector: '[my-custom-validator][ngmodel]' })
what multiple '[...]' (brackets) selection mean?
as in css, selector [attr]
matches elements have attribute named attr
. when multiple attribute selectors chained together, all attributes must exist on element.
note: unlike css, angular ignores [...]
or [(...)]
binding brackets on target attribute when performs match.
thus, selector [my-custom-validate][ngmodel]
matches elements have both my‑custom‑validate
attribute , ngmodel
attribute (including [ngmodel]
, [(ngmodel)]
). example, selector matches
<input type="text" name="username" my-custom-validate [(ngmodel)]="model.username">
but not
<input type="text" name="username" my-custom-validate>
Comments
Post a Comment