Nincompoops Producing Methane
Miss any of our Open RFC calls?Watch the recordings here! »

angular-required

1.1.0 • Public • Published

Angular Required

Angular 2+ decorator to make @Input required

NPM

Install with npm:

npm install angular-required --save

Usage example

For example, to display the map it is necessary to specify latitude and longitude. If you forgot to specify one of the parameters, then you will see the corresponding error message in the console.

alt text

app.component.ts

@Component({
  selector: 'app-root',
  template: '<app-map [latitude]="29.58"></app-map>',
})
export class AppComponent {}

map.component.ts

@Component({
  selector: 'app-map',
  template: `
    <div>Latitude: {{latitude}}</div>
    <div>Longitude: {{longitude}}</div>
    <div *ngIf="zoom">Zoom: {{zoom}}</div>
  `,
})
export class MapComponent {
  @Input() @Required() latitude: number;
  @Input() @Required() longitude: number;
  @Input() zoom: number;
}

Install

npm i angular-required

DownloadsWeekly Downloads

4

Version

1.1.0

License

ISC

Unpacked Size

3.42 kB

Total Files

8

Last publish

Collaborators

  • avatar