【发布时间】:2015-11-22 22:03:31
【问题描述】:
我尝试包含 http://krescruz.github.io/angular-materialize/#select,但我在控制台中遇到错误(您可以在图像中看到)。这个问题有什么解决方案吗,这里是angular-materialize.js中的指令
angular.module("ui.materialize.material_select", [])
.directive("materialSelect", ["$compile", "$timeout", function ($compile, $timeout) {
return {
link: function (scope, element, attrs) {
if (element.is("select")) {
$compile(element.contents())(scope);
function initSelect() {
element.siblings(".caret").remove();
element.material_select();
}
$timeout(initSelect);
if (attrs.ngModel) {
scope.$watch(attrs.ngModel, initSelect);
}
if ("watch" in attrs) {
scope.$watch(function () {
return element[0].innerHTML;
}, function (oldVal, newVal) {
if (oldVal !== newVal) {
$timeout(initSelect);
}
});
}
}
}
};
}]);
【问题讨论】:
-
错误很明显:
element.isis not a function..如果使用jQuery方法,只需加载jQuery即可。
标签: angularjs materialize