Wie man nach dart2js eine Dart-Methode aus Javascript aufruft
Ich habe dieses Dart-Skript unten und möchte mit JavaScript auf die Methoden der Klasse hello_world zugreifen, nachdem ich das Dart-Skript mit dart2js kompiliert habe. Weiß jemand, wie das funktioniert ?! Ich weiß bereits, wie man auf Funktionen wie foo (...) zugreift, das ist nicht das Problem, aber es funktioniert nicht auf die gleiche Weise mit Klassen und Methoden. In den Tutorials auf dartlang.org wird nur der Zugriff auf Funktionen und nicht auf Methoden und Klassen erläutert. Ich verstehe es nicht ...
import 'dart:js' as js;
class hello_world {
String hello = 'Hello World!';
String getHello() {
print("getHello!!!!!");
return hello;
}
void ausgabe() {
print("Hallo Welt");
//return 0;
}
}
String foo(int n) {
print("hallo");
void foo2() {
print("hallo2");
}
//works
js.context['foo2'] = foo2;
return 'Hallo';
}
void main() {
int zahl1 = 3;
int zahl2 = 1234;
String w = 'test';
hello_world test = new hello_world();
//works
js.context['foo'] = foo;
}