Port to AngularJS