Currently inside my NG2 app I'm using a resolver, that makes a connection to signalr.
I have configured the resolver inside my route config, so when navigation to the destination page, the resolve function is called accordingly.
I've managed to show an animation when the destination page is initialized.
However, I would like to show an 'is-busy' like animation DURING the resolving of my resolver, but I don't know how to do this. Any suggestions?
This is my current setup:
//resolver.ts
@Injectable()
export class ConnectionResolver implements Resolve<SignalRConnectionMock> {
constructor(private _signalR: SignalR) {}
resolve() {
console.log('HomeRouteResolver. Resolving...');
return new SignalRConnectionMock();// this._signalR.connect();
}
}
//inside route.ts
{ path: 'docs',
component: DocumentationComponent,
resolve: { connection: ConnectionResolver }
}
//router.ts
import { trigger, state, animate, style, transition } from '@angular/core';
//router.transition.ts
export function routerTransition() {
return slideToLeft();
}
function slideToLeft() {
return trigger('routerTransition', [
state('void', style({position: 'fixed', width: '100%'}) ),
state('*', style({position: 'fixed', width: '100%'}) ),
transition(':enter', [ // before 2.1: transition('void => *', [
style({transform: 'translateX(100%)'}),
animate('0.5s ease-in-out', style({transform: 'translateX(0%)'}))
]),
transition(':leave', [ // before 2.1: transition('* => void', [
style({transform: 'translateX(0%)'}),
animate('0.5s ease-in-out', style({transform: 'translateX(-100%)'}))
])
]);
}
//home.component.ts
import { routerTransition } from './route.transition';
@Component({
selector: 'home',
animations: [routerTransition()],
host: {'[@routerTransition]': ''}
})
export class HomeComponent {}