E2E mock $httpBackend doesn’t actually passThrough for me

I stumbled on the same problem but instead of implementing a rich API or replacing the original angular-mocks simply added in the following helper: angular.module(‘httpReal’, [‘ng’]) .config([‘$provide’, function($provide) { $provide.decorator(‘$httpBackend’, function() { return angular.injector([‘ng’]).get(‘$httpBackend’); }); }]) .service(‘httpReal’, [‘$rootScope’, function($rootScope) { this.submit = function() { $rootScope.$digest(); }; }]); It patches two issues that prevent an HTTP … Read more

Confused about how to handle CORS OPTIONS preflight requests

I sat down and debugged through the org.apache.catalina.filters.CorsFilter to figure out why the request was being forbidden. Hopefully this can help someone out in the future. According to the W3 CORS Spec Section 6.2 Preflight Requests, the preflight must reject the request if any header submitted does not match the allowed headers. The default configuration … Read more

scope and controller instantiation with ui router

To get even more detailed answers, we can/should observe the source code and check the documentation. Let me try to explain all three questions (and also cite from code and doc). 1. When do controllers get instantiated? Here we can observe the code of the ui-view directive: [$ViewDirective.$inject = \[‘$state’, ‘$injector’, ‘$uiViewScroll’, ‘$interpolate’\];][1] Controllers are … Read more

Good way to dynamically open / close a popover (or tooltip) using angular, based on expression?

You can also build your own extended triggers. This will apply to both Tooltip and Popover. First extend the Tooltip triggers as follows: // define additional triggers on Tooltip and Popover app.config([‘$tooltipProvider’, function($tooltipProvider){ $tooltipProvider.setTriggers({ ‘show’: ‘hide’ }); }]); Then define the trigger on the HTML tag like this: <div id=”RegisterHelp” popover-trigger=”show” popover-placement=”left” popover=”{{ ‘Login or … Read more

What is $$phase in AngularJS?

$$phase is a flag set while angular is in a $digest cycle. Sometimes (in rare cases), you want to check $$phase on the scope before doing an $apply. An error occurs if you try to $apply during a $digest: Error: $apply already in progress

AngularJS – Directives vs Controllers

Here’s a brief stand-alone answer, with links to official docs for further info (definition of “services” added for good measure): http://docs.angularjs.org/guide/controller In AngularJS, a controller is a JavaScript constructor function that is used to augment the AngularJS scope. When a controller is attached to the DOM via the ng-controller directive, AngularJS will instantiate a new … Read more

Highlighting a filtered result in AngularJS

In did that for AngularJS v1.2+ HTML: <span ng-bind-html=”highlight(textToSearchThrough, searchText)”></span> JS: $scope.highlight = function(text, search) { if (!search) { return $sce.trustAsHtml(text); } return $sce.trustAsHtml(text.replace(new RegExp(search, ‘gi’), ‘<span class=”highlightedText”>$&</span>’)); }; CSS: .highlightedText { background: yellow; }

Angularjs – Hide content until DOM loaded

In your CSS add: [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; } and just add a “ng-cloak” attribute to your div like here: <div id=”template1″ ng-cloak>{{scoped_var}}<div> doc: https://docs.angularjs.org/api/ng/directive/ngCloak