Encountering an error in the browser after adding a string parameter to the constructor of my class:
https://i.sstatic.net/Hh1wM.png
The structure of my class is as follows:
import { Component, OnInit } from '@angular/core';
import { MatrixComponent } from '../matrix/matrix.component';
@Component({
selector: 'app-player',
templateUrl: './player.component.html',
styleUrls: ['./player.component.css']
})
export class PlayerComponent implements OnInit {
private userName: string;
constructor(private name: string) {
this.userName = name;
this.discovered = 0;
this.matrix = new MatrixComponent();
}
ngOnInit() {
}
}
Creating an object within the constructor of another class:
var player1 = new PlayerComponent("Me");
Is it correct to pass parameters in the constructor? Can you identify what's causing the issue in my code?