MaterializeCSS select not working with ng-repeat

2019-07-14 02:17发布

MaterializeCSS select with repeated options (using ng-repeat) is not working. Kindly assist!

<div class="col s12 input-field">
    <select ng-model="selected-category" id="category" name="category" class="">
        <option value="" selected>Choose Category</option>
        <option ng-repeat="c in categories" value="c.catCode">{{c.catDescription}}</option>
    </select>
</div>

1条回答
叼着烟拽天下
2楼-- · 2019-07-14 02:53

I'm having a similar problem.

According to the MaterializeCSS documentation, you need to initialize your select with this:

$(document).ready(function() { $('select').material_select(); });

You also need to call $('select').material_select();again after your ng-repeat is compiled in order for your select to have the correct options populated.

Source: http://materializecss.com/forms.html#select-initialization

查看更多
登录 后发表回答