Skip to content

Commit f9cdb86

Browse files
committed
Merge pull request #388 from piethis/master
ui-sref using resolved promises now updates.
2 parents 818b0d6 + 3832635 commit f9cdb86

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/stateDirectives.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function $StateRefDirective($state) {
3535

3636
if (ref.paramExpr) {
3737
scope.$watch(ref.paramExpr, function(newVal, oldVal) {
38-
if (newVal !== oldVal) update(newVal);
38+
if (newVal !== params) update(newVal);
3939
}, true);
4040
params = scope.$eval(ref.paramExpr);
4141
}

test/stateDirectivesSpec.js

+15
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ describe('uiStateRef', function() {
5252
el[0].dispatchEvent(e);
5353
}
5454

55+
describe('links with promises', function() {
56+
it('should update the href when promises on parameters change before scope is applied', inject(function($rootScope, $compile, $q) {
57+
promise = $q.defer()
58+
el = angular.element('<a ui-sref="contacts.item.detail({ id: contact.id })">Details</a>');
59+
scope = $rootScope;
60+
scope.contact = promise.promise;
61+
promise.resolve({id: 6});
62+
scope.$apply();
63+
$compile(el)(scope);
64+
scope.$digest();
65+
66+
expect(el.attr('href')).toBe('#/contacts/6');
67+
}));
68+
});
69+
5570
describe('links', function() {
5671

5772
beforeEach(inject(function($rootScope, $compile) {

0 commit comments

Comments
 (0)