如何结合使用 MaterializeCSS 和 AngularJS 来初始化 <select>?
How do I initialize <select> using MaterializeCSS and AngularJS combined?
我一直在尝试向我的页面添加一个简单的 < select > 片段,但我发现 , MaterializeCSS starts off by disabling it, and then re-enables (I'm assuming) once the correct jQuery plugin has been loaded (using directives, as shown by this answer)
我还没有找到一个很好的例子来说明如何使用 AngularJS 来做到这一点,如果可能的话,我想避免转向 angular 设计的 Materialise 分支。
这是我得到的。
<label>
test
<select material-select>
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
</label>
我打算制作一个初始化 < select > 的指令,然后我将使用 ng-repeat 来填充它。
navApp.directive('myDropDown', function() {
return {
//This code is broken, I am not quite sure what I'm doing.
restrict: 'A',
link: function(scope, element, attrs) {
$(element).'select'.material_select();
}
};
});
我认为自己是 ASP.NET MVC、实体框架(使用 MySQL)和 AngularJS 的新手,这些都是我目前正在使用的框架。
我也找到了this resource on creating directives,但我不知道如何适应我的情况。
对于这方面的任何帮助,我将不胜感激。
$(element).'select'.material_select();
这条语句的结果应该是什么? .'select'
不是 JS 语法。
尝试:
$(element).material_select(); // if the element is already the select element
或:
$(element).find('select').material_select(); // find a child select of the element
我一直在尝试向我的页面添加一个简单的 < select > 片段,但我发现
我还没有找到一个很好的例子来说明如何使用 AngularJS 来做到这一点,如果可能的话,我想避免转向 angular 设计的 Materialise 分支。
这是我得到的。
<label>
test
<select material-select>
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
</label>
我打算制作一个初始化 < select > 的指令,然后我将使用 ng-repeat 来填充它。
navApp.directive('myDropDown', function() {
return {
//This code is broken, I am not quite sure what I'm doing.
restrict: 'A',
link: function(scope, element, attrs) {
$(element).'select'.material_select();
}
};
});
我认为自己是 ASP.NET MVC、实体框架(使用 MySQL)和 AngularJS 的新手,这些都是我目前正在使用的框架。
我也找到了this resource on creating directives,但我不知道如何适应我的情况。
对于这方面的任何帮助,我将不胜感激。
$(element).'select'.material_select();
这条语句的结果应该是什么? .'select'
不是 JS 语法。
尝试:
$(element).material_select(); // if the element is already the select element
或:
$(element).find('select').material_select(); // find a child select of the element