Having trouble using the takePicture() function from camera.ts in my home.ts. I keep getting an error message saying "No provider for CameraPage!" Any assistance on how to resolve this issue would be greatly appreciated, as I am new to this language and just started learning it a few days ago.
home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {NavParams} from 'ionic-angular';
import { CameraPage } from '../../pages/camera/camera';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController,public navParams: NavParams, private camera: CameraPage) {
}
goCam(){
this.camera.takePicture();
}
}
camera.ts
import { Component } from '@angular/core';
import {Camera} from 'ionic-native';
import { NavController } from 'ionic-angular';
@Component({
templateUrl: 'camera.html'
})
export class CameraPage {
public base64Image: string;
constructor(public navCtrl: NavController) {
}
takePicture(){
Camera.getPicture({
destinationType: Camera.DestinationType.DATA_URL,
targetWidth: 1000,
targetHeight: 1000
}).then((imageData) => {
// imageData is a base64 encoded string
this.base64Image = "data:image/jpeg;base64," + imageData;
}, (err) => {
console.log(err);
});
}
ionViewWillEnter(){
this.takePicture();
}
}
tabs.ts
import { Component } from '@angular/core';
import { HomePage } from '../home/home';
import { CameraPage } from '../camera/camera';
import { ContactPage } from '../contact/contact';
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage {
// this tells the tabs component which Pages
// should be each tab's root Page
tab1Root: any = HomePage;
tab2Root: any = CameraPage;
tab3Root: any = ContactPage;
constructor() {
}
}