Rewrite with AngularJS