Using an object to define data that is displayed in a component. Piping in the data from a json file for now which is read in via the Http service, and getting this error:
and it looks like it is failing within my main component which is here:
import { Component, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { Contribution } from '../contribution';
import { ContribService } from '../contrib.service';
import { Card } from '../card';
import { Group } from '../group';
@Component({
providers: [ContribService],
selector: 'main',
templateUrl: './main.component.html',
styleUrls: ['./main.component.css']
})
export class MainComponent implements OnInit{
contrib:Contribution = new Contribution();
constructor(private contribService: ContribService){
}
ngOnInit(){
this.contribService.getContribution().subscribe(data=>this.contrib = data);
}
maskCard: boolean = true;
unmaskedCard: string = this.contrib.thisCard.number;
maskedCard: string = 'XXXXXXXXXXXX' + this.unmaskedCard.substring(11,15);
displayedCard: string = this.maskedCard;
maskToggle = function(): void{
if(this.maskCard == true){
this.displayedCard = this.maskedCard;
}else{
this.displayedCard = this.unmaskedCard;
}
}
}
From what I understand, the error is more than likely an issue with the object "thisCard".
How can I get around it?