1

I am trying to get value of data attribute inside component.ts in angular2.

1) form2.component.html

<md-select  placeholder = "BedRooms" [formControl]="userForm.controls['bedRooms']" >
    <md-option #bedRoom  *ngFor="let bedRooms of formSettings?.prices?.pricingParams?.bedRooms" [value] = bedRooms.title [attr.data-price] = bedRooms.price (click)="test(bedRoom)"> {{bedRooms?.title}} </md-option>
</md-select>

How to get value of data-price in test function?

1

1 Answer 1

4

You can access the value of data-price from reference bedRoom as below.

bedRoom.getAttribute('data-price');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.