I generated a sample Polymer web project. Added following js file.
jslib.js
function testfunction()
{
alert("test");
}
in clickcounter.dart I added dependency
import 'package:js/js.dart' as js;
and changed increment() function
void increment() {
js.context.testfunction();
count++;
}
In clickcounter.html added js file import
<script src="jslib.js" type="text/javascript"></script>
And in main html file added
<script src="packages/browser/interop.js"></script>
It works correctly when in executed in Dartium. When I compile it to javascript however it gives an error
Uncaught NoSuchMethodError : method not found: 'Symbol("testfunction")'
Receiver: Instance of 'Proxy'
Arguments: [] js_helper.dart:870
Stack Trace:
Error
at Object.wrapException (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:4632:13)
at Proxy.Object.noSuchMethod$1 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:33708:13)
at Proxy_noSuchMethod_closure.call$0 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:109612:46)
at Object.Proxy.static.Proxy__forward (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:109581:45)
at Proxy.noSuchMethod$1 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:109492:14)
at Proxy.Object.testfunction$0 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:56090:17)
at ClickCounter.increment$0 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:7080:50)
at CachedInvocation.invokeOn$2 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:6221:28)
at JsInstanceMirror._invoke$4 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:12998:35)
at JsInstanceMirror.invoke$3 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:12963:17)