Rewrite with using Angularjs