I am new to Angular and I have started to write my first test. Could someone help me understand how the dependency injection works ?
I have a class called Level.ts which looks something like this:
export class Level {
Title: string,
isTitle: boolean
}
and my actual component called Previewer.component.ts which looks like
import { Input,Component, OnInit } from '@angular/core';
import { Level} from '../Level';
@Component({
selector: 'app-previewer',
templateUrl: './previewer.component.html',
styleUrls: ['./previewer.component.css']
})
export class Previewer implements OnInit {
@Input() level: Level;
confirmTitle(){
this.level.Title = "Level 1";
this.level.isTitle = true;
}
}
I must add that I am not using a service currently and would want to test the previewer.component.ts file. However when I run the test, it throws an error saying that 'TypeError: Cannot read property 'isTitle' of undefined'. I have also used the NO_ERRORS_SCHEMA, but still I get this error thown. Kindly help
Aucun commentaire:
Enregistrer un commentaire