File

packages/ui/src/lib/notifications/error/error.component.ts

Description

The CrudComponent takes at least a model name to render an entry list with create/edit/delete functionality out of the box.

Implements

OnInit OnChanges

Metadata

selector ec-error
templateUrl ./error.component.html

Index

Methods
Inputs

Constructor

constructor(symbol: SymbolService)
Parameters :
Name Type Optional
symbol SymbolService No

Inputs

error
Type : any

The error that should be displayed

Methods

ngOnChanges
ngOnChanges()

change update

Returns : void
ngOnInit
ngOnInit()

initial update

Returns : void
update
update()

updates error message

Returns : void
import { Component, Input, OnChanges, OnInit } from '@angular/core';
import { SymbolService } from '../../symbol/symbol.service';

/** The CrudComponent takes at least a model name to render an entry list with create/edit/delete functionality out of the box.  */
@Component({
  selector: 'ec-error',
  templateUrl: './error.component.html',
})
/** Displays an error thrown by the SDK. */
export class ErrorComponent implements OnInit, OnChanges {
  /** The error that should be displayed */
  @Input() error: any;

  constructor(private symbol: SymbolService) {}

  /** initial update */
  ngOnInit() {
    this.update();
  }
  /** change update */
  ngOnChanges() {
    this.update();
  }
  /** updates error message  */
  update() {
    if (!this.error) {
      return;
    }
    const message = this.symbol.resolve('error.' + this.error.code);
    if (message) {
      this.error.message = message;
    }
  }
}
<span *ngIf="error?.code">{{error.code}}</span>
<span *ngIf="error?.dataPath">{{error.dataPath}}</span>
{{error?.message}}
<small>{{error.detail}}{{error.verbose?': '+error.verbose:''}}</small>
<ul *ngIf="error?.subErrors">
  <li *ngFor="let subError of error.subErrors">
    <ec-error [error]="subError"></ec-error>
  </li>
</ul>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""