|
1 |
| -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; |
2 |
| -import {MenuItem, MessageService} from 'primeng/api'; |
| 1 | +import { Component, OnInit, ViewEncapsulation, Input } from '@angular/core'; |
| 2 | +import { MenuItem } from 'primeng/api'; |
3 | 3 |
|
4 | 4 | @Component({
|
5 |
| - selector: 'btd-stepper', |
6 |
| - templateUrl: './stepper.component.html', |
7 |
| - styleUrls: ['./stepper.component.scss'], |
8 |
| - encapsulation: ViewEncapsulation.None, |
9 |
| - providers: [MessageService], |
| 5 | + selector: 'btd-stepper', |
| 6 | + templateUrl: './stepper.component.html', |
| 7 | + styleUrls: ['./stepper.component.scss'], |
| 8 | + encapsulation: ViewEncapsulation.None |
10 | 9 | })
|
11 | 10 | export class StepperComponent implements OnInit {
|
| 11 | + @Input() activeIndex = 1; |
12 | 12 |
|
13 |
| - items: MenuItem[]; |
14 |
| - activeIndex = 1; |
15 |
| - constructor(private messageService: MessageService) {} |
| 13 | + steps: MenuItem[]; |
| 14 | + constructor() { } |
16 | 15 |
|
17 |
| - ngOnInit() { |
18 |
| - this.items = [{ |
19 |
| - command: (event: any) => { |
20 |
| - this.activeIndex = 0; |
21 |
| - this.messageService.add({severity: 'info', summary: 'Algo 1', detail: event.item.label}); |
22 |
| - } |
23 |
| - }, |
24 |
| - { |
25 |
| - command: (event: any) => { |
26 |
| - this.activeIndex = 1; |
27 |
| - this.messageService.add({severity: 'info', summary: 'Algo 2', detail: event.item.label}); |
28 |
| - } |
29 |
| - }, |
30 |
| - { |
31 |
| - command: (event: any) => { |
32 |
| - this.activeIndex = 2; |
33 |
| - this.messageService.add({severity: 'info', summary: 'Algo 3', detail: event.item.label}); |
34 |
| - } |
35 |
| - }, |
36 |
| - { |
37 |
| - command: (event: any) => { |
38 |
| - this.activeIndex = 3; |
39 |
| - this.messageService.add({severity: 'info', summary: 'Algo 4', detail: event.item.label}); |
40 |
| - } |
41 |
| - }, |
42 |
| - { |
43 |
| - command: (event: any) => { |
44 |
| - this.activeIndex = 4; |
45 |
| - this.messageService.add({severity: 'info', summary: 'Algo 5', detail: event.item.label}); |
46 |
| - } |
47 |
| - } |
48 |
| -]; |
49 |
| -} |
| 16 | + ngOnInit() { |
| 17 | + |
| 18 | + this.steps = [ |
| 19 | + {label: 'Algo 1'}, |
| 20 | + {label: 'Algo 2'}, |
| 21 | + {label: 'Algo 3'}, |
| 22 | + {label: 'Algo 4'}, |
| 23 | + {label: 'Algo 5'}, |
| 24 | + ]; |
| 25 | + } |
50 | 26 | }
|
0 commit comments