How to reset $dirty in form

What you are looking for is $setPristine(). You’ll find it in the docs here: http://docs.angularjs.org/api/ng/type/form.FormController When a form first loads on the page it is in a state called pristine. You’ll find that form.$pristine is true and form.$dirty is false. Once any changes have been made to any element that has an Angular binding, those … Read more

angular ui modal after close event

I will assume that you are using the Modal dialogs from angular-ui. But before going into the details a bit of documentation around promises in AngularJS is needed. You need to know that every then function can accept 3 parameters as such : then(successCallback, errorCallback, notifyCallback) successCallback is executed when the promise is resolved. errorCallback … Read more

How to close Angular UI Modal from anywhere

Inject the $modalStack service and call the function $modalStack.dismissAll(), see the code on GitHub for details: myApp.factory(‘ModalService’, [‘$modal’, ‘$modalStack’ function($modal, $modalStack) { return { trigger: function(template) { $modal.open({ templateUrl: template, size: ‘lg’, controller: function($scope, $modalInstance) { $scope.ok = function() { $modalInstance.close($scope.selected.item); }; $scope.cancel = function() { $modalInstance.dismiss(‘cancel’); }; } }); }, close: function(reason) { $modalStack.dismissAll(reason); … Read more

Handle open/collapse events of Accordion in Angular

Accordion groups also allow for an accordion-heading directive instead of providing it as an attribute. You can use that and then wrap your header in another tag with an ng-click. <accordion-group ng-repeat=”group in groups” heading=”{{group.title}}” is-open=”group.open”> <accordion-heading> <span ng-click=”opened(group, $index)”>{{group.content}}</span> </accordion-heading> </accordion-group> Example: http://plnkr.co/edit/B3LC1X?p=preview

Adding ui.bootstrap dependency with bower

You are installing a wrong package from bower. The correct one to install is bower install angular-bootstrap as described here: https://github.com/angular-ui/bootstrap#installation Edit: As of February 2015, a Bower version of the library exists at https://github.com/angular-ui/bootstrap-bower. Unfortunately, it presently only contains AngularUI Bootstrap 0.12.0 which, as far as I can tell, isn’t fully compatible with Angular … Read more

UI-router interfers with $httpbackend unit test, angular js

Take this gist https://gist.github.com/wilsonwc/8358542 angular.module(‘stateMock’,[]); angular.module(‘stateMock’).service(“$state”, function($q){ this.expectedTransitions = []; this.transitionTo = function(stateName){ if(this.expectedTransitions.length > 0){ var expectedState = this.expectedTransitions.shift(); if(expectedState !== stateName){ throw Error(“Expected transition to state: ” + expectedState + ” but transitioned to ” + stateName ); } }else{ throw Error(“No more transitions were expected! Tried to transition to “+ stateName ); … Read more