我目前在AngularJS應用程序中移動代碼,並開始接收客戶指令中的錯誤。該指令在原始版本中工作正常,但在移動了一些內容後返回了下面列出的錯誤。AngularJS指令對象有「沒有方法」
我一直在通過代碼嘗試找到我錯過的參考文件,關閉的文件版本或任何其他原因,以便突然出現此錯誤。我很遺憾沒有找到任何東西。
什麼可能導致AngularJS指令發生以下錯誤?
TypeError: Object [object Object] has no method 'slider'
at link (http://localhost:8000/static/modeling/js/directives/slider.js:9:13)
at k (http://localhost:8000/static/js/angular.min.js:44:444)
at e (http://localhost:8000/static/js/angular.min.js:40:139)
at e (http://localhost:8000/static/js/angular.min.js:40:156)
at e (http://localhost:8000/static/js/angular.min.js:40:156)
at e (http://localhost:8000/static/js/angular.min.js:40:156)
at k (http://localhost:8000/static/js/angular.min.js:44:382)
at e (http://localhost:8000/static/js/angular.min.js:40:139)
at e (http://localhost:8000/static/js/angular.min.js:40:156)
at http://localhost:8000/static/js/angular.min.js:39:205 <slider id="slider" scale="scale" class="span2 ng-isolate-scope ng-scope">
我的指令定義如下:
myApp.directive('slider', function() {
return {
restrict: 'E',
scope: {
scale: '='
},
link: function(scope, elm, attrs) {
console.log(elm);
elm.slider({ // !! THIS IS LINE 9 (per error message) !!
min: 1,
max: 50,
step: 1,
value: 30,
slide: function(event, ui) {
scope.scale = ui.value;
scope.$apply();
}
})
}
}
});
正在使用的示例HTML標籤是:
<slider id="slider" scale="scale" class="span2"></slider>
看起來你可能會忘記包括jQueryUI的在你重新配置應用程序。 – Lukas
謝謝!請提供答案,以便我可以進一步解決問題! :) –