0.0.1 • Published 6 years ago

http-status-pipe v0.0.1

Weekly downloads
2
License
MIT
Repository
-
Last release
6 years ago

HttpStatusPipe

Build Status


Angular 5

This package will not work with earlier versions of Angular!


This project contains an Angular 5 pipe that can be used for rendering an arbitrary status code's status text or status type. The pipe, HttpStatusPipe, is exported from the HttpStatusModule.

Demo

NPM

npm install --save http-status-pipe

Usage

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpStatusModule } from 'http-status-pipe';

import { AppComponent } from './app.component';


@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        HttpStatusModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }

./src/app/app/module.ts

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    public statusCode: number = 200;
    constructor() {}
}

src/app/app.component.ts

<h1 id="status-code">
    Error {{ statusCode }}
    <small>
        {{ statusCode | status }}
    </small>
</h1>
<p>{{ statusCode | status:"type" }}</p>

src/app/app.component.html