Git Product home page Git Product logo

angularhx's Introduction

angular.hx

Haxe bindings for angular.js

Implemented

Controller

Create controllers by implementing angularhx.IAngularController.

@controllerName('TestCtrl')
@inject('$scope', '$http')
class TestController implements IAngularController {

	function new(scope:Scope, http:Http) {
		...
	}
}
  • @controllerName is mandatory, it defines the name of the controller from the HTML perspective. If omitted the class name will be used.
  • @inject is mandatory, list services by their names which will be injected into the controller. The injection will be safe for JavaScript minification.
  • The services will be injected in the same order as in the @inject meta data.

Note: It is up to you ensure the correct types of the injected services!

Scope

To be more typesafe and more Haxe-ish you could create classes around local scopes. Therefore create a class and extend angularhx.IAngularScope.

class ControllerData implements IAngularScope  {

	private var name:String;
	private var readOnly:Bool;

	public function new(defaultName:String) {
		setName(defaultName);
	}

	public function setName(name:Null<String>) {
		this.name = name;
		this.readOnly = name == null;
	}
}


/// In your controller

@inject('$scope')
class TestController implements IAngularController {

	function new(scope:Scope) {
		var scopeData = new ControllerData("defaultName", scope);
	}
}
  • Every property and method is accessible from HTML
  • In HTML classes are flat (there is no difference between static and non static properties)

Note: When creating a scope instance you need to add an additional parameter (the scope you got from angular) to the contructor!

HTTP service

The are binding for the $http service. Example:

http.get('test.json').success(function(data) {
	trace("success: " + data);
	// do something with data
}).error(function(data, statusCode) {
	trace('error ${statusCode}');
});

TODO

  • create wrappers for creating own services
  • create wrappers for creating own filters

Development

To prepare you local checkout for development you need node.js installed.

$ make prepare

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.