(Ionic 2) The plugin located here seems to not work for me on android and ios : http://ionicframework.com/docs/native/printer/
I think that I followed the guidelines from this page, the code is building on both platforms but I got a black screen on ios and a blank one on android when emulate ...
First I started a new project : ionic start PrinterApp --v2
Then I installed platforms : android 6.2.1, ios 4.3.1
Then the two command lines from the plugin page :
ionic plugin add --save de.appplant.cordova.plugin.printer
npm install --save @ionic-native/printer
Then in the home.html I put a line to active the printer :
<button class="button" (click)="print()">Print</button>
And finally my home.ts looks like this :
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Printer, PrintOptions } from '@ionic-native/printer';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, private printer: Printer) {
}
print() {
this.printer.isAvailable();
let options: PrintOptions = {
name: 'MyDocument',
duplex: true,
landscape: true,
grayscale: true
};
this.printer.print("http://google.com", options);
}
}
Did anyone have this kind of troubles with the plugin ? Did I do something wrong ? Should I install other things to fix the problem ? And did anyone have a exemple project working well ?
Thank you very much !
With the help of Suraj and Gabriel I managed to fix the problem, I needed to go to this page to get informations : http://ionicframework.com/docs/native/#Add_Plugins_to_Your_App_Module
And so typing this line : npm install @ionic-native/core --save
Then into my App.Module.ts adding printer provider like this :
Thanks again ! Have a great day
ionic cordova plugin add --save isiigo-cordova-plugin-printer
npm install --save @ionic-native/printer