]>
Commit | Line | Data |
---|---|---|
1 | import { Component, Input, OnInit } from '@angular/core' | |
2 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
3 | ||
4 | @Component({ | |
5 | selector: 'my-edit-button', | |
6 | styleUrls: [ './button.component.scss' ], | |
7 | templateUrl: './edit-button.component.html' | |
8 | }) | |
9 | ||
10 | export class EditButtonComponent implements OnInit { | |
11 | @Input() label: string | |
12 | @Input() title: string | |
13 | @Input() routerLink: string[] | string = [] | |
14 | ||
15 | constructor (private i18n: I18n) { } | |
16 | ||
17 | ngOnInit () { | |
18 | // <my-edit-button /> No label | |
19 | if (this.label === undefined && !this.title) { | |
20 | this.title = this.i18n('Update') | |
21 | } | |
22 | ||
23 | // <my-edit-button label /> Use default label | |
24 | if (this.label === '') { | |
25 | this.label = this.i18n('Update') | |
26 | ||
27 | if (!this.title) { | |
28 | this.title = this.label | |
29 | } | |
30 | } | |
31 | } | |
32 | } |