Split AngularJS logic into dedicated controller and service file. More work on the spring security side.