Dear,
i faced a porblem in ionic 2. when i run my project, it show error “Error in ./MyApp class MyApp - caused by: No component factory found for OrderServices”.
order.ts
import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
import { OrderServices } from ‘…/…/app/services/order.service’;
@Component({
selector: ‘orders’,
templateUrl: ‘order.html’
})
export class OrderPage {
items: any;
category: any;
limit:any;
constructor(public navCtrl: NavController, private orderService:OrderServices) {
}
ngOnInit(){
this.getPosts(this.category, this.limit);
}
getDefaults(){
this.category = 'sports';
this.limit = 10;
}
getPosts(category, limit){
this.orderService.getPosts(category, limit).subscribe(response => {
this.items = response.data.children;
});
}
order.service.ts
import {Injectable} from ‘@angular/core’;
import {Http} from ‘@angular/http’;
import ‘rxjs/Rx’;
@Injectable()
export class OrderServices{
http:any;
baseUrl: String;
constructor(http:Http){
this.http = http;
this.baseUrl = 'https://www.reddit.com/r';
}
getPosts(category, limit){
debugger
return this.http.get(this.baseUrl+'/'+category+'/top.json?limit='+limit)
.map(res => res.json());
}
}