gpt4 book ai didi

javascript - AngularJS - 引用错误 : $ is not defined

转载 作者:数据小太阳 更新时间:2023-10-29 04:19:24 25 4
gpt4 key购买 nike

当我尝试执行此操作时出现以下错误

var fbcanvas = $('#fbcanvas');

这是我得到的错误

ReferenceError: $ is not defined

这是我的JS代码

var feedbackModule = angular.module('feedbackModule', [ 'ui.bootstrap', 'dialogs' ]);

feedbackModule.controller('feedbackDialog', function($scope, $rootScope, $timeout, $dialogs) {
$scope.confirmed = 'You have yet to be confirmed!';
$scope.name = '"Your name here."';

$scope.sendFeedback = function() {

html2canvas(document.body, {
onrendered: function(canvas) {
var data = canvas.toDataURL('image/png'), dlg = null;

dlg = $dialogs.create('js/plugin/vzfeedbacktool.html', 'feedbackToolController', {
imgdata: data
}, {
key: false,
back: 'static'
});
dlg.result.then(function(name) {
$scope.name = name;
}, function() {
$scope.name = 'You decided not to enter in your name, that makes me sad.';
});

}
});
}; // end launch

});

feedbackModule.controller('feedbackToolController', ['$scope', '$modalInstance', function($scope, $modalInstance, data) {

$scope.cancel = function() {
$modalInstance.dismiss('canceled');
}; // end cancel

$scope.save = function() {
debugger;
var fbcanvas = $('#fbcanvas');
var ctx = fbcanvas.getContext('2d');
var image = new Image();

image.src = data.imgdata;
ctx.drawImage(image, 0, 0);
}; // end save

}]);

知道我是否遗漏了什么吗?顺便说一下,如果我尝试直接在控制台中执行该代码,它工作正常 :S

谢谢

最佳答案

试试这个:

var fbcanvas = document.getElementById('fbcanvas');

代替:

var fbcanvas = $('#fbcanvas');

检查数据是否也是 undefined

关于javascript - AngularJS - 引用错误 : $ is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30773161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com