ng-service2resolve
v1.0.3
Published
Simple way convert Service to Resolve.
Downloads
2
Readme
NgService2Resolve
Simple way convert Service to Resolve.
Install
npm install ng-service2resolve
Getting Started
// Import method and function
import { Service2ResolveModule, service2Resolve } from './service2resolve';
// deceive AOT compiler, fix `Function calls are not supported in decorators` problem
export let timeResolve = null, valueResolve = null;
// use service2Resolve function create Resolve class
timeResolve = service2Resolve([MyTestService], (services, route, state) => {
return services[0].getTime();
});
const routes: Routes = [
{
path: '',
pathMatch: 'full',
component: MyTestComponent,
resolve: {
time: timeResolve //Add Routing Resolve,
time2: service2Resolve(//this way not support AOT. If use this way, you can use findResolves function get all Resolve of routes
[MyTestService],
(services, route, state) => {
return services[0].getTime();
}
)
}
}
];
@NgModule({
imports: [
Service2ResolveModule, // very important!
RouterModule.forRoot(routes)
],
providers: [findResolves(routes), timeResolve], // findResolves function NOT SUPPORT AOT
exports: [RouterModule]
})
export class AppRoutingModule {}