Command pattern implementation for AngularJS