Skip to content

Commit

Permalink
fix(router.ats): expose "navigating" property
Browse files Browse the repository at this point in the history
  • Loading branch information
btford committed Mar 27, 2015
1 parent 97f89d9 commit 7d56e3d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/router.ats
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,22 @@ class Router {
return Promise.reject();
}

instruction.router = this;
this._startNavigating();

instruction.router = this;
return this.pipeline.process(instruction)
.then(() => this._finishNavigating(), () => this._finishNavigating())
.then(() => instruction.canonicalUrl);
}

_startNavigating() {
this.navigating = true;
}

_finishNavigating() {
this.navigating = false;
}


makeDescendantRouters(instruction) {
this.traverseInstructionSync(instruction, (instruction, childInstruction) => {
Expand Down
14 changes: 14 additions & 0 deletions test/router-viewport.es5.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,20 @@ describe('ngViewport', function () {
expect(elt.text()).toBe('one');
}));


it('should expose a "navigating" property on $router', function () {
$router.config([
{ path: '/one', component: 'one' }
]);
compile('<div ng-viewport></div>');

$router.navigate('/one');
expect($router.navigating).toBe(true);
$rootScope.$digest();
expect($router.navigating).toBe(false);
});


function registerComponent(name, template, config) {
if (!template) {
template = '';
Expand Down

0 comments on commit 7d56e3d

Please sign in to comment.