Use AngularJS $q if jQuery is undefined and AngularJS is defined