Having some trouble with JsInterop while wrapping up a piece of JavaScript code.
The JavaScript code looks like this:
com = { gwidgets: {} };
com.gwidgets.Spring = function () {
this.name = "hello";
};
com.gwidgets.Spring.prototype.getName = function () {return "test";
};
Here is the JsInterop class:
package com.gwidgets.leaflet;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsType;
@JsType(isNative=true)
public class Spring {
@JsMethod
public native String getName();
}
However, I encounter an error when I try to instantiate the class and call the getName()
method:
leafletwrapper-0.js:1183 Uncaught TypeError: spring.getName is not a function
Can anyone help me identify what's wrong with my code?