Materializecss Select + angularjs

梦想的初衷 提交于 2019-12-12 03:43:09

问题


I have this bug that I can't find and I don't know how to fix. I searched how to make the materializecss select work with angularjs. this is the code I found.

function materialSelect($timeout) {
            var directive = {
                link: link,
                restrict: 'E',
                require: '?ngModel'
            };

            function link(scope, element, attrs, ngModel) {

                $timeout(create);
                if (ngModel) {
                    ngModel.$render = create;
                }

                function create() {
                    element.material_select();
                }

                //if using materialize v0.96.0 use this
                element.one('$destroy', function () {
                    element.material_select('destroy');
                });


            }

            return directive;
        }

But Now, there's bug in every select I have. Sometimes, the select is only 1. the first select don't have any value. the options are inserted in 2nd select. sometimes there's only 1 select and We're praying for that to always happen. When I first used angularjs there's no bug like that. but now that our system is near in completion, that bug shows up

    <select id="cREmp123" ng-model="vm.selEmployee"
ng-options="employee.strEmpFirstName for employee in vm.employeeList">
<option value="" selected>Choose...</option>
</select>

来源:https://stackoverflow.com/questions/39647390/materializecss-select-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!