I am new to ionic I am following ionic framework documents to learn it.
Here is my method's code: hello-ionic.ts
openActionSheet(){
let actionSheet=this.actionsheetCtrl.create(
{
title: 'Modify your album',
cssClass: 'page-hello-ionic',
buttons:[
{
text: 'Delete',
role: 'destructive', //will always sort to be on top
icon: !this.platform.is('ios') ? 'trash' : null,
handler: () => {
console.log('Delete clicked');
}
},
{
text: 'Play',
icon: !this.platform.is('ios') ? 'arrow-dropright-circle' : null,
handler: () => {
console.log('Play clicked');
}
},
{
text: 'Favorite',
icon: !this.platform.is('ios') ? 'heart-outline' : null,
handler: () => {
console.log('Favorite clicked');
}
},
{
text: 'Cancel',
role: 'cancel', // will always sort to be on the bottom
icon: !this.platform.is('ios') ? 'close' : null,
handler: () => {
console.log('Cancel clicked');
}
}
]});
actionSheet.present();
}
The code works fine. But I want to know that where is console.log()
printed. Can anyone help me with that?
To access the logs open Android Studio, click the logcat in the bottom toolbar and then in the logcat window, select your device and provide the filtering options and log level(info, error).
To see it on the browser you need to open the debugging console. To do so do a right click and then click on the "Inspect" option. To use the console. log("hello") from your Ionic app, just add this line anywhere in your code.
Preview URL App Mode You can switch between previewing different modes of your application by clicking the "iPhone" dropdown in the top right of the Web preview. This allows you to choose other devices like Android or a tablet.
To check the console log you can use browser and run the below command:
Step 1: $ionic serve
(will run your app on localhost)
Step 2: In your respective browser (chrome, safari, etc...) where your app is running Right + click and inspect your app as per below screenshot.
Step 3: You will get a window with HTML elements on the right side of your browser window and on the left your app screen.
Step 4: On the right side window, you can find "Console" menu option on the top bar. Click on that you will get your console where you find your app logs or error or warning which ionic generated.
EDIT: Real Device or Emulator debugging
To check real-device
or emulator
or genymotion
console logs follow the below steps & screenshots.
Step 1: Run this command to run your app on real-device or emulator
$ionic cordova run android
Step 2: After successfully launch the app on device or emulator Go to Chrome browser and Right + click and click on "Inspect" and you will get below screen at bottom of your browser.
Step 3: Click on "Remote devices" will show connected real device or emulator list.
From that device list click on "Inspect" button on the right side of that device name(check screenshot for the same) will open a new window with your device mirror now console is yours play around with this debugger.
Hope this will help you to debug your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With