I just released a project "HaxeAngularSupport", a macro for haxe/angularjs

56 views
Skip to first unread message

Freewind

unread,
Jan 22, 2013, 7:59:34 AM1/22/13
to haxe...@googlegroups.com
Hi, all:

I just released a small project called "HaxeAngularSupport": https://github.com/freewind/HaxeAngularSupport

If you are using angularjs with haxe, you may be interested in. It provided a macro "AngularSupport", we can write angular controllers this way:

class MyCtrl implements Public, implements AngularSupport {

    @AngularSupport({inject:['$scope', '$http'], scope:'$scope'})
    function new(scope:Dynamic, http:Dynamic) {
        this.http = http;
        // don't need to assign "scope" to anything
    }

    var http:Dynamic;
    var name = "Freewind";
    function hello() {
        js.Lib.alert(name);
    }
}

Instead of:

class MyCtrl implements Public {

public static function __init__() {
js.Lib.eval("MyCtrl.$inject = ['$scope', '$http'];");
}
function new(scope:Scope, http:Dynamic) {
scope.name = "Freewind";
scope.hello = function() {
js.Lib.alert(scope.name);
}
}
}

private typedef Scope = {
name:String,
hello: Void -> Void
}

Which makes the code cleaner.

Thanks for everybody's help there days, especially for "back2dos". Thanks for all of you!

Juraj Kirchheim

unread,
Jan 22, 2013, 8:05:14 AM1/22/13
to haxe...@googlegroups.com
Glad to see you finally got it to work ;)

Freewind

unread,
Jan 22, 2013, 8:18:26 AM1/22/13
to haxe...@googlegroups.com
I was nearly gave up because of that "type inference" issue, but today I found another way which is much simpler than previous one, and it works.

Thank you back2dos :)

Cambiata

unread,
Jan 22, 2013, 8:31:01 AM1/22/13
to haxe...@googlegroups.com
:-)
Reply all
Reply to author
Forward
0 new messages