Bir plunker yarattı oluşturulmuyorsa ama krom konsolunda ararken bu işe yapabilmek görünmüyor, ben çözemiyorum bir hata neden var ...Angular2 bileşeni
EXCEPTION: TypeError: Cannot read property 'toString' of undefined
https://plnkr.co/edit/a7F616WCoKbSGXzlYGsM?p=preview
Neyse, benim sorum benim hata eXEMPLE yaratmaktı, plunker ilgili değildi.
bileşen hat listesi ... [] bileşen dekoratör ve render değildir: Ben başka bir bileşen kullanmak istediğiniz bir bileşene sahip
, bunu ithal ve direktifleri onu ekledi .component, onun seçici gb-line-list ve ben bu dosya app/alan-list.component.ts içinde kullanmaya çalışıyorum.
Hiç net olmadığımı hissediyorum, ancak plunker'ımın düzgün çalışmasını sağlayamam.
alan-detail.component.ts
import {Component, Input, OnInit} from 'angular2/core';
import {RouteParams} from 'angular2/router';
import {LineListComponent} from './line-list.component';
import {Area} from './area.interface';
import {LineService} from './lines.service';
@Component({
selector: '[gb-area-detail]',
directives: [LineListComponent],
template: `
<div *ngIf="area">
<h2>{{area.name}} area</h2>
<gb-line-list [areaId]="area.id"></gb-line-list>
</div>
`
})
export class AreaDetailComponent implements OnInit {
private area: Area;
constructor(
private _lineService: LineService,
private _routeParams: RouteParams){}
ngOnInit() {
let id = +this._routeParams.get('id');
this._lineService.getArea(id)
.then(area => this.area = area);
}
}
satır list.component.ts
import {Component, OnInit, Input} from 'angular2/core';
import {LineService} from './lines.service';
import {Line} from './line.interface';
@Component({
selector: '[gb-line-list]',
template: `
<ul>
<li *ngFor="#line of lines">{{line.name}}</li>
</ul>
`
})
export class LineListComponent implements OnInit {
@Input() areaId: number;
private lines: Line[];
constructor (
private _lineService: LineService) {}
getLines() {
this._lineService.getLines(this.areaId)
.then(lines => this.lines = lines);
}
ngOnInit() {
this.getLines();
}
}
düzenleme: orada gerçek bir sorun tanımlayan Component not rendering properly
Oh ve çevremde olduğumda, kromun konsolunda hata yok ... – JCorriveau