Posts tagged with 'AngularJS'

Mocking Angular’s $http Promise return type using only Mocks

Last week, we had a look at Mocking Angular’s $http Promise return type using the $q library. This gives you a great deal of control over when your mock promises are resolved. But, it comes at the cost of requiring both the $q library and manually calling $rootscope.$apply(). If you want to avoid those (and you don't…

Mocking Angular’s $http Promise return type

The Angular $http service provides an easy way to interact with an API endpoint. If you want to query some data, you can simply do this: var request = $http.get('/api/items'); request.success(function (data) { console.log('I have data', data); }); The request object above is an Angular HTTP promise (ng.IHttpPromise…

Writing Cleaner AngularJS with TypeScript and ControllerAs

Our team made the move to TypeScript and Angular at the tail end of last year. I'd had a look at Angular a year or so ago but struggled to get my head around the excessive usage of $scope and the nesting of $parent items that needed to be traversed. Since then (with version 1.2.0), Angular now supports Controller As…