material icon indicating copy to clipboard operation
material copied to clipboard

md-select, md-option: using html in the option does not apply to selected element

Open DmitryEfimenko opened this issue 11 years ago • 15 comments

Easier to show an example. I have an array of options in the controller:

var opts = [
    { val: 1, text: '<span class="op">Fancy</span> Text 1' },
    { val: 2, text: '<span class="op">Fancy</span> Text 2' },
    { val: 3, text: '<span class="op">Fancy</span> Text 3' },
    { val: 4, text: '<span class="op">Fancy</span> Text 4' },
]

Notice that each item in the opts has text property with html. my md-select looks like this:

<md-select ng-model="myModel">
    <md-option ng-repeat="op in opts" ng-value="op.val">
        <span ng-bind-html="op.text"></span>
    </md-option>
</md-select>

Notice the use of ng-bind-html This produces the following option (example shows just first option):

<md-option ng-repeat="op in opts" ng-value="op.val" tabindex="0" class="ng-scope" role="option" aria-selected="false" id="select_option_00V" value="==">
    <div class="md-text">
        <span ng-bind-html="op.text" class="ng-binding">
            <span class="op">Fancy</span> Text 1
        </span>
    </div><div class="md-ripple-container"></div>
</md-option>

That all looks good. However, once this option is selected it looses the html I provided:

<md-select ng-model="myModel" class=".." [...deleted for simplicity]>
    <md-select-label class="md-select-label" id="select_label_007">
        <span>Fancy Text 1</span>
        <span class="md-select-icon" aria-hidden="true"></span>
    </md-select-label>
</md-select>

Notice a <span>Fancy Text 1</span>. It does not have the html I provided anymore.

DmitryEfimenko avatar Apr 10 '15 04:04 DmitryEfimenko

Would be great if you would support md-iconinside of md-select-optionor better in the result of md-select-label. Currently it simply doesn't align well inside of the overlay and didn't display the icon inside of the md-select-label. Here is a codepen, where you see the alignment issue and the selected element won't display the icon: http://codepen.io/anon/pen/mJqMrx

dohomi avatar Jun 24 '15 04:06 dohomi

Pair w/ @topherfangio

ThomasBurleson avatar Aug 10 '15 21:08 ThomasBurleson

+1

erinjanae avatar Sep 17 '15 21:09 erinjanae

+1

richardchristian avatar Sep 24 '15 13:09 richardchristian

+1

audiodude avatar Oct 06 '15 16:10 audiodude

+1

hulyav avatar Oct 09 '15 08:10 hulyav

+1

breity avatar Nov 10 '15 17:11 breity

+1

ishener avatar Dec 06 '15 15:12 ishener

+1

StartingDreams avatar Jan 23 '16 23:01 StartingDreams

+1

DoKraus avatar Jul 07 '17 12:07 DoKraus

+1

vsilva472 avatar Jul 09 '17 21:07 vsilva472

+1

ghost avatar Aug 08 '17 10:08 ghost

@NathanaelDekeister the output is not different for me. When the item is selected, the icon is not displayed. I see only the text: "face"

behavior is the same for me like in the initial plunker

tux1337 avatar Dec 29 '17 20:12 tux1337

+1

T4YoO avatar Mar 14 '18 13:03 T4YoO

I don't know what the +1s mean after this was released in 1.0.0-rc.5. If you are having an issue related to this functionality, please open a new issue with a CodePen demo of the problem. Please avoid using +1 in the future and use GitHub reactions instead as those allow us to sort and filter issue based on number of reactions.

Splaktar avatar Mar 14 '18 23:03 Splaktar