Egy nagyon szép megoldás. AngularJS GWT-s controllerrel. Így komplex alkalmazáslogikát fejleszthetünk az app-hoz Java-ban, amit AngularJS-el lehet a HTML elemekhez rendelni egy sor JavaScript nélkül ...
Originally shared by Ray Cromwell
Write AngularJs Controllers and Scopes in GWT? Crazy? Lookie what I did as an experiment with generators + elemental.
@NgName("BodyController")
public class BodyController extends AngularController {
public void onInit(BodyScope scope, Element element) {
scope.setBlah("Hello");
}
}
public interface BodyScope extends Scope {
String getBlah();
void setBlah(String s);
String doSomething();
}
{{blah}}
That's it. The rest is magic. This publishes a window scoped controller function for ng-controller directives to attach to which invokes the onInit() function. BodyScope is an auto-generated type-safe Javascript overlay (extends JsonObject from Elemental) that is created for you and injected into the onInit() For each getter/setter, it puts a field on $scope, and for every other method, it installs a function on $scope that can be called. For each type argument you declare in the onInit() argument list, it automatically sets up Controller.$inject for you. @NgName allows you to override the automatically discovered name of the controller of desired (by default, Class.getSimpleName() )
With super-dev-mode, you can work simultaneously with debugging raw angular JS code and stepping into Java code, all inside of Chrome.
Nincsenek megjegyzések:
Megjegyzés küldése