Initial port to AngularJS