0
私のプロジェクトでng2に問題があります。私はこのエラーが続いています: "app/korisnik_oglasi/moji_oglasi.html:29:27の原因:self.parent.parent.context.aktivirajOglasは関数ではありません"と私はそれをどうすればいいのかわかりません。エラーが原因で発生しました:self.parent.parent.context.aktivirajOglasは関数ではありません
これは私のコンポーネントです:
import { Component,OnInit} from '@angular/core';
import { OglasiService } from '../oglasi/oglasi.service';
import { Router,ActivatedRoute,Params } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { Oglas } from '../oglasi/oglas';
import 'rxjs/add/operator/switchMap';
@Component({
templateUrl: 'app/korisnik_oglasi/moji_oglasi.html',
})
export class KorisnikOglasComponent implements OnInit {
private _korisnik = './app/korisnik/korisnik.json';
errorMessage: string;
id: number;
oglas : Oglas;
constructor(
private oglasiService: OglasiService,
private route: ActivatedRoute,
private router: Router
) { }
ngOnInit(): void {
/* this.id = this.route.params
.switchMap((params: Params) => { this.id = +params['id']; });*/
this.oglasiService.dohvatiOglas(this.id)
.subscribe(data => this.oglas = data,
error => this.errorMessage = <any>error);
}
public aktivirajOglas(oglas: Oglas):void{
//TODO
console.log("Oglas aktiviran");
}
}
そして、これは私のテンプレートです:
<section *ngIf ="oglasi" class="pulldown40 row">
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Naziv oglasa</th>
<th>Datum kreiranja oglasa</th>
<th>Datum ažuriranja oglasa</th>
<th>Datum prestanka oglasa</th>
<th>Status</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let oglas of oglasi">
<td>{{oglas.id}}</td>
<td>{{oglas.naziv}}</td>
<td>15.11.2016</td>
<td>16.11.2016</td>
<td>21.11.2016</td>
<td>{{oglas.status_opis}}</td>
<td><a routerLink="/mojiOglasi/{{oglas.id}}">Uredi</a></td>
<td><a (click)="aktivirajOglas(oglas);">Aktiviraj</a></td>
</tr>
</tbody>
</table>
</section>
問題は、このaktivirajOglas機能です。それはそれを認識しません。
誰かが何をすべきか知っていますか?
対タイプミス
oglas
があるように思わ 'oglas'と' oglasi'といくつかのタイプミスはありますか?テンプレートは 'oglasi'を使いますが、' oglas'プロパティだけがあります。 –Plunkerを更新して問題を再現できますか? https://plnkr.co/edit/qWq8FtwKp25wziL8Gz3v?p=preview –
@GünterZöchbaueromg、そうです。実際、私は間違ったコンポーネントのすべての時間この関数でそれが認識されなかった理由です。どうもありがとうございます。 – Veki