Reputation:
I'm trying to add multiple values to the data-content
attribute using angular. In order for me to target the data-content attribute I'm using the [attr.data-content]
angular code for it to work.
I have a list of address I loop through and I'm trying to add multiple values to the data-content attribute e.g. address.FriendlyName and address.Description. When I add more than one property it doesn't work. Does any know how to get it working?
See the code below:
<select class="selectpicker form-control m-input">
<option *ngFor="let address of dummyAddresses" [attr.data-content]="address.FriendlyName address.Description">This is a test</option>
<option data-content="Add …">Add new address</option>
</select>
Upvotes: 0
Views: 1056
Reputation: 5446
You can do string concatenation inside of attribute bindings:
<select class="selectpicker form-control m-input">
<option *ngFor="let address of dummyAddresses" [attr.data-content]="address.FriendlyName + ' ' + address.Description">This is a test</option>
<option data-content="Add …">Add new address</option>
</select>
You should make sure that your options do not include spaces to avoid creating artifacts
Upvotes: 1