Skip to content

Commit

Permalink
Merge pull request #388 from piethis/master
Browse files Browse the repository at this point in the history
ui-sref using resolved promises now updates.
  • Loading branch information
nateabele committed Sep 6, 2013
2 parents 818b0d6 + 3832635 commit f9cdb86
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/stateDirectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function $StateRefDirective($state) {

if (ref.paramExpr) {
scope.$watch(ref.paramExpr, function(newVal, oldVal) {
if (newVal !== oldVal) update(newVal);
if (newVal !== params) update(newVal);
}, true);
params = scope.$eval(ref.paramExpr);
}
Expand Down
15 changes: 15 additions & 0 deletions test/stateDirectivesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ describe('uiStateRef', function() {
el[0].dispatchEvent(e);
}

describe('links with promises', function() {
it('should update the href when promises on parameters change before scope is applied', inject(function($rootScope, $compile, $q) {
promise = $q.defer()
el = angular.element('<a ui-sref="contacts.item.detail({ id: contact.id })">Details</a>');
scope = $rootScope;
scope.contact = promise.promise;
promise.resolve({id: 6});
scope.$apply();
$compile(el)(scope);
scope.$digest();

expect(el.attr('href')).toBe('#/contacts/6');
}));
});

describe('links', function() {

beforeEach(inject(function($rootScope, $compile) {
Expand Down

0 comments on commit f9cdb86

Please sign in to comment.