Gowthaman
Gowthaman

Reputation: 852

TypeScript with Jquery

I am getting this error "Uncaught ReferenceError: $ is not defined" please find my code below.

///<reference path="jquery.d.ts" />

class Test {
    name: string;

    constructor() {
        this.name = "gowtham";
    }

    dispname() {
        alert("Name :" + this.name);
    }
}

$(document).ready(function () {

    debugger;
    var test = new Test();
    $('#test').on('click', function() {
        debugger;
        test.dispname();
    });

});

i am having the referance too reference path="jquery.d.ts" in my .ts file. Am i missing anything here .?

Upvotes: 1

Views: 3939

Answers (1)

Vadim Macagon
Vadim Macagon

Reputation: 14847

You're getting a runtime error because you haven't loaded JQuery properly, if the issue was with the typings then you would've seen a compiler error.

See existing question: Uncaught ReferenceError: $ is not defined?

Upvotes: 3

Related Questions