angular - Angular2 @Input issue -
i new angular2 , trying hand using @input not able proceed because of below issue. after @input component not proceed further. have verified in chrome developer tools , see execution goes outside class after @input
import {component, input, oninit} 'angular2/core'; import {http, http_providers} 'angular2/http'; import 'rxjs/rx'; var availablejobs = []; @component({ selector: 'job-categories', templateurl:'templates/job.categories.html', providers:[http_providers] }) export class jobcategories{ @input('rows') rows: string; @input('cols') columns: string; constructor(http: http){ http.get('appjs/dummyjson.json').map(res => res.json()).subscribe( (data) => { availablejobs = data; console.log(availablejobs); }); } }
could please me overcome.
the html tag
i see problem in code. forgot this
keyword within subscribe
callback:
constructor(http: http){ http.get('appjs/dummyjson.json').map(res => res.json()).subscribe( (data) => { this.availablejobs = data; // <----- console.log(this.availablejobs); }); } }
this way able see / use availablejobs
property in template of component...
Comments
Post a Comment