Answer the question
In order to leave comments, you need to log in
How to fix in Angular2 Cannot read property 'value' of undefined?
I can't figure out where the error is.
There is a component with the following code:
<router-outlet>
<div class="releasesMenu" *ngIf="detailedInfo">
<h1>Releases</h1>
<div class="search">
<input type="text" #search (keyup)="0" placeholder="Find release by its name, song or year">
</div>
</div>
<div class="releasesOutlet container">
<div class="row releasesBlock">
<div *ngFor="let release of (releases| searchFilter: search.value )" class="releaseRender" (click)="onSelect(release)">
<div class="releaseRenderWrap" *ngIf="!selectedRelease">
<span>Something interesting...</span>
</div>
</div>
<div class="releaseDetails" *ngIf="selectedRelease">
<div class="releaseDetailsWrap">
<span>Some details...</span>
</div>
</div>
</div>
</div>
</router-outlet>
import { Component, OnInit } from '@angular/core';
import { SearchFilter } from './../search-filter.pipe';
import { ReleasesService } from '../releases/releases.service';
@Component({
selector: 'releases-component',
providers: [ReleasesService],
templateUrl: './app/releases/releases.component.html',
styleUrls: ['./app/releases/releases.component.css','./css/grid.css']
})
export class ReleasesComponent implements OnInit {
releases: any = [];
release: any;
selectedRelease: any;
private detailedInfo: boolean;
onSelect(release){
this.detailedInfo = false;
this.selectedRelease = release;
console.log(release)
}
constructor(private releasesService: ReleasesService){ }
ngOnInit(){
this.releasesService.getReleases()
.subscribe(data => this.releases = data);
}
}
(click)="onSelect(release)
remove the block with the class class="releasesMenu"
. *ngIf="detailedInfo"
try, but I keep getting errors like Cannot read property 'value' of undefined . Answer the question
In order to leave comments, you need to log in
You have an error in another expression. Namely in
search.value. search variable not in scope
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question