Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

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

Closed
DmitryEfimenko opened this issue Apr 10, 2015 · 15 comments

Comments

@DmitryEfimenko
Copy link

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.

@dohomi
Copy link

dohomi commented Jun 24, 2015

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

@ThomasBurleson
Copy link
Contributor

Pair w/ @topherfangio

@erinjanae
Copy link

+1

3 similar comments
@richardchristian
Copy link

+1

@audiodude
Copy link

+1

@hulyav
Copy link

hulyav commented Oct 9, 2015

+1

@ThomasBurleson ThomasBurleson modified the milestones: 1.0-rc1, 1.0-rc2, 1.0-rc3 Oct 27, 2015
@ThomasBurleson ThomasBurleson modified the milestones: 1.0-rc3, 1.0-rc4 Nov 7, 2015
@breity
Copy link

breity commented Nov 10, 2015

+1

@ishener
Copy link

ishener commented Dec 6, 2015

+1

4 similar comments
@StartingDreams
Copy link

+1

@DoKraus
Copy link

DoKraus commented Jul 7, 2017

+1

@vsilva472
Copy link

+1

@ghost
Copy link

ghost commented Aug 8, 2017

+1

@tux1337
Copy link

tux1337 commented Dec 29, 2017

@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

@T4YoO
Copy link

T4YoO commented Mar 14, 2018

+1

@Splaktar
Copy link
Member

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.

@angular angular locked as resolved and limited conversation to collaborators Mar 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests