Each $q.reject() throws an error if not being chained properly. First check that all calls have a .catch(). Second, if possible, isolate your error cases to an independent describe block. Example below using bardjs, but the idea should be clear enough. let stuffDataservice; const stuff = [{}]; beforeEach(function() { [...] stuffDataservice = { getStuff: function […]
Tag Archives: AngularJS
When developing CRMs autocomplete is often useless or altogether detrimental. If you end up having a case where no element will ever need autocomplete, one of the fastest ways to achieve this is hooking an AngularJS directive to the form element: (function() { 'use strict'; angular .module('app.core') .directive('form', htmlFormDirective); function htmlFormDirective() { return { restrict: […]
AngularJS ng-repeat limitTo with Objects
13-Jun-17<div ng-repeat="(key, value) in object | limitTo: 2"> will not work, as ngRepeat needs a string or an array to work with. A workaround is to use ng-if="$index < 2". <div ng-repeat="(key, value) in object" ng-if="$index < 2"> Do note that the order of keys for any given object may vary.
Google Analytics and Angular UI Router
20-Mar-17Tracker service: (function () { 'use strict'; angular .module('app.core') .service('googleAnalyticsTracker', googleAnalyticsTracker); googleAnalyticsTracker.$inject = ['$state', '$window']; function googleAnalyticsTracker($state, $window) { /* jshint validthis: true */ this.trackState = trackState; //////////////// function trackState() { var stateName = $state.current.name; var path = stateName.replace(/\./g, '/'); // replaces dots to mimic regular path with slashes $window.ga('set', 'page', path); $window.ga('send', 'pageview'); } […]