Angular routing engine that drive views by media types. It loads data itself, and by response Content-Type
header
it displays configured view. It is a replacement for original Angular Router (they cannot be used at the same time).
The aim of this library is to allow building of RESTful clients using Angular, following HATEOAS principle.
See CHANGELOG for release changes.
npm i angular-resource-router --save
See API documentation for latest released version.
Sample snippet how is the router configured. It is very similar to original router, but instead of registering paths, we are registering media types.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ResourceRouterModule } from 'angular-resource-router';
import { AppComponent } from './app.component';
import { SampleComponent } from './sample.component';
import { ErrorComponent } from './error.component';
@NgModule({
declarations: [
AppComponent,
SampleComponent
],
imports: [
BrowserModule,
ResourceRouterModule.configure({
prefix: 'api/'
}),
ResourceRouterModule.forTypes([
{
type: 'application/x.sample',
component: SampleComponent
},
{
status: '*',
type: '*',
component: ErrorComponent
}
])
],
bootstrap: [
AppComponent
]
})
export class ExampleModule {
}
TODO
Before development, run
npm run bootstrap
it will create necessary symlinks for build to pass.
Note: Under linux, you need to change global npm prefix to user accessible directory, see How to Prevent Permissions Errors.
Build of the library is performed with
npm run build
To publish new library version to npm repository:
src/lib/package.json
v0.0.0
(or alternatively use git directly)npm run bootstrap
npm run build
npm run buildapp
npm publish dist/angular-resource-router
npm run ghpages
Local development server can be started with
npm start
Things that are yet to be implemented
resolve
and data
route configs