First commit
This commit is contained in:
63
src/app/pages/card/cards/cards.page.ts
Normal file
63
src/app/pages/card/cards/cards.page.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ModalController, MenuController, NavController, Events } from '@ionic/angular';
|
||||
import { EnvService } from 'src/app/services/env.service';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { IchambaService } from 'src/app/services/ichamba.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { AlertService } from 'src/app/services/alert.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-cards',
|
||||
templateUrl: './cards.page.html',
|
||||
styleUrls: ['./cards.page.scss'],
|
||||
})
|
||||
export class CardsPage implements OnInit {
|
||||
|
||||
cards = [];
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
private menu: MenuController,
|
||||
private navCtrl: NavController,
|
||||
private events: Events,
|
||||
private authService: AuthService,
|
||||
private alertService: AlertService,
|
||||
private ichambaService: IchambaService,
|
||||
private translateService: TranslateService,
|
||||
private env: EnvService,
|
||||
) {
|
||||
this.events.subscribe('refreshcards', (data) => {
|
||||
this.getcards();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.getcards();
|
||||
}
|
||||
|
||||
newcard() {
|
||||
this.navCtrl.navigateForward('/addcard');
|
||||
}
|
||||
|
||||
|
||||
getcards() {
|
||||
this.ichambaService.getCard().subscribe(
|
||||
data => {
|
||||
this.cards = data;
|
||||
}, error => {
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
|
||||
});
|
||||
}
|
||||
|
||||
deletecard(id: String) {
|
||||
this.ichambaService.deleteCard(id).subscribe(
|
||||
data => {
|
||||
this.getcards();
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.deleted_card'));
|
||||
}, error => {
|
||||
this.alertService.presentToast(this.translateService.instant('alerts.error') + error['status']);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user