Krish
Krish

Reputation: 4242

Attribute binding in angular

i am trying to highlighted selected radio button using Attribute Binding but i am not getting result can some one help me please

css

input:default {
  box-shadow: 0 0 1px 1px red;
}

html

<input type="radio" name="gender" value="male" [attr.default]="value=='male'" (click)="value='male'"> Male<br>
<input type="radio" name="gender" value="female" [attr.default]="value=='female'" (click)="value='female'"> Female<br>
<input type="radio" name="gender" value="other" [attr.default]="value=='others'" (click)="value='other'"> Other

Below my stackblitz link

https://stackblitz.com/edit/angular-648y1w?file=src/app/app.component.html

Upvotes: 2

Views: 317

Answers (1)

Just code
Just code

Reputation: 13791

Your css selector is wrong

it should be like this

input[type="radio"][default="true"] {
  box-shadow: 0 0 1px 1px red;
}

demo

Upvotes: 1

Related Questions