AngularJS - ReferenceError:$未定义 [英] AngularJS - ReferenceError: $ is not defined

查看:95
本文介绍了AngularJS - ReferenceError:$未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试这样做时出现以下错误

I'm getting the following error when I try to do this

var fbcanvas = $('#fbcanvas');

这是我得到的错误


ReferenceError: $未定义

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

Any idea if I'm missing something? by the way, if I try to execute that code directly in the console it works fine :S

谢谢

推荐答案

试试这个:

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

而不是:

var fbcanvas = $('#fbcanvas');

检查数据是否 undefined

这篇关于AngularJS - ReferenceError:$未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆