import {Http} from '@angular/http';
@Injectable()
export class StudentService{
constructor(public http: Http){}
getAllStudents(): Observable<Students[]>{
return this.http.get('assets/students.json')
.map(res => res.json().data)
}
}
notice the constructor now again if we want to use this service method we will go to our view/page and :
import {StudentService} from './student.service';
import { SocialSharing } from '@ionic-native/social-sharing';
export class HomePage implements OnInit {
constructor(public _studentService: StudentService, public socialSharing: SocialSharing) {
}
again notice the constructor here, we are creating an instance of StudentService in constructor and one more thing, we are using socialSharing plugin so to use that we are creating instance of that in constructor as well.