Veki Veki - 9 days ago 9
HTML Question

Error in ... caused by: self.parent.parent.context.aktivirajOglas is not a function

I am having problem with ng2 in my project. I keep getting this error:
"Error in app/korisnik_oglasi/moji_oglasi.html:29:27 caused by: self.parent.parent.context.aktivirajOglas is not a function" and I don't know what to do with it.

This is my component:

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");
}
}


And this is my template:

<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>


Problem is in this aktivirajOglas function. It doesn't recognize it.

Does someone knows what to do?

Answer

There seems to be a typo oglas vs oglasi

Plunker example

Comments