Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all 48980 articles
Browse latest View live

Error on Upload image and also the uploaded image will update the database for changing profile picture (PHP)

$
0
0

@kimjosh187 wrote:

uploadImage(){
if(this.clickedImagePath = null){
this.presentToast(“Don’t leave any field.”);
}

else{
  const actionSheet = this.actionSheetCtrl.create({
    title: 'Update changes?',
    buttons: [
      {
        text: 'Yes',
        handler: () => {
          let loader = this.loadingCtrl.create({
            content: "Uploading..."
          });
          loader.present();


    let completeUrl = this.url;
    let postData = new FormData()
    postData.append('file', this.clickedImagePath, this.userid);
    let data:Observable<any> = this.http2.post(completeUrl, postData);
    data.subscribe((result) => {
      console.log(result);
      alert("Success");
      loader.dismiss();
    }, (err) => {
      console.log(err);
      alert("Error");
      loader.dismiss();
    });
  }
},{
  text: 'Cancel',
  role: 'cancel',
  handler: () => {
    console.log('Cancel clicked');
  }
}

]
});
actionSheet.present();
}
}

This is my code for uploading image to the server

<?php $data = [ 'result' => false]; $target_path = time().'.jpg'; if (isset($_POST['file'])) { $img = mysqli_real_escape_string($con, $_REQUEST['img']); $id = mysqli_real_escape_string($con, $_REQUEST['id']); $sql1 = mysqli_query($con,"SELECT * from sl_user where u_id = '".$id."'"); $row=mysqli_fetch_array($sql1); $imgs = $row['u_image']; $sql4 = "UPDATE sl_user SET u_image='".$img."' WHERE u_id='".$id."'"; if(mysqli_query($con,$sql4)) { $row_array['type'] = "sucess"; die(json_encode($row_array)); } else{ $row_array['msg'] = 'Ooops - something went wrong: '.mysqli_error($con); $row_array['type'] = "error"; die(json_encode($row_array)); } $imagedata = $_POST['file']; $imagedata = str_replace('data:image/jpeg;base64','', $imagedata); $imagedata = str_replace('data:image/jpg;base64','', $imagedata); $imagedata = str_replace(' ','+', $imagedata); $imagedata = base64_decode($imagedata); file_put_contents($target_path, $imagedata); $data['result'] = true; $data['image_url'] = 'http://slcal.net/images/'.$target_path; } header('Access-Control-Allow-Origin: *'); header('Content-Type: application/json'); echo json_encode($data); ?>

This is the php server code

It will not upload and also update the database.
I would appreciate those who help me with this error. Thanks

Posts: 1

Participants: 1

Read full topic


How to get value from multiple check box as well as textbox

$
0
0

@flycoders_sourav wrote:

I have a multiple a check and when user clicks on anyone checkbox there open a text box and the user can put there any value in this textbox also i attached my desire outputScreenshot_97
.html

  <ion-item *ngFor="let abc of serviceList">
      <ion-label>{{abc.servicenam}}</ion-label>
      <ion-checkbox color="dark" (click)="isActive = !isActive"></ion-checkbox>
  </ion-item>
  <div *ngIf="isActive">
      <button color="light" ion-button small>Red</button>
      <button color="light" ion-button small>Green</button>
      <button color="light" ion-button small>Yellow</button>
      <button color="light" ion-button small>Blue</button>
   </div>

please help me out

Posts: 1

Participants: 1

Read full topic

How to identify if a bluetooth device is a printer in ionic

$
0
0

@fordyfy wrote:

can you teach me how to scan only bluetooth device? i don’t know how to do it. here’s my code. My goal is to get only type of bluetooth printer devices.

printer classs

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ModalController, AlertController, ToastController  } from 'ionic-angular';
import {PrintProvider} from '../../providers/print/print';
import { DatabaseProvider } from '../../providers/database/database';

@IonicPage()
@Component({
  selector: 'page-printer',
  templateUrl: 'printer.html',
})
export class PrinterPage {
  SelectedPrinter:any = [];
  Bluetooth_Printer_List:any = []
  Bluetooth_Name: string = null
  Bluetooth_ID: string = null
  Bluetooth_Address:string = null
  Bluetooth_Device_List:any = []

  constructor(public navCtrl: NavController, public navParams: NavParams, private modalCtrl:ModalController,
    private printProvider:PrintProvider, private alertCtrl:AlertController, 
    public toastCtrl: ToastController, private database: DatabaseProvider) {
  }

  ionViewDidLoad() {
    
  }

  ionViewDidEnter(){
    this.getBluetoothPrinter()
  }

  getBluetoothPrinter(){
    this.database.readBluetoothPrinter().then(data=>{
      this.Bluetooth_Printer_List = data
      this.Bluetooth_Name = this.Bluetooth_Printer_List[0].bluetooth_name
      this.Bluetooth_Address = this.Bluetooth_Printer_List[0].bluetooth_address
      this.Bluetooth_ID = this.Bluetooth_Printer_List[0].bluetooth_id
    }, (error) => {
      console.log(error);
    })
  }

  listBTDevice()
  {
    this.printProvider.searchBt().then(datalist=>{
      
      this.Bluetooth_Device_List = datalist
      this.showBluetoothDeviceList()

    },err=>{
      this.errorToast(err);
    })
  }

  testConnectPrinter()
  {
    var id = this.Bluetooth_ID

    if(id==null||id==""||id==undefined)
    {
      //nothing happens, you can put an alert here saying no printer selected
      this.informationtoast("Please select printer.");
    }
    else
    {
        this.printProvider.connectBT(id).subscribe(data=>{
          this.informationtoast("Connected successfully!");
      },err=>{
        this.informationtoast(err);
      });
    }
  }

  testPrinter()
  {
    var id = this.Bluetooth_ID
    if(id==null||id==""||id==undefined)
    {
      //nothing happens, you can put an alert here saying no printer selected
      this.informationtoast("Please select printer.");
    }
    else
    {
      this.printProvider.formatPrint(id);
    }
  }

  informationtoast(textMessage: string) {
    const toast = this.toastCtrl.create({
      message: textMessage,
      duration: 3000,
      cssClass: 'information-toast'

    });
    toast.present();
  }

  errorToast(textMessage: string) {
    const toast = this.toastCtrl.create({
      message: textMessage,
      duration: 3000,
      cssClass: 'error-toast'
    });
    toast.present();
  }

  saveDefaultBlutoothPrinter(){
    this.database.insertBluetoothPrinter(this.SelectedPrinter);
    this.getBluetoothPrinter()
  }
  

  showBluetoothDeviceList() {

    let alert = this.alertCtrl.create();
    alert.setTitle('Bluetooth device list');

    for(var i = 0; this.Bluetooth_Device_List.length > i ; i++){
      alert.addInput({
        type: 'radio',
        label: this.Bluetooth_Device_List[i].name,
        value: this.Bluetooth_Device_List[i].name
      });
    }
  
    alert.addButton('Cancel');
    alert.addButton({
      text: 'OK',
      handler: data => {
       this.getBluetoothDeviceData(data)
       this.saveDefaultBlutoothPrinter()
      }
    });
    alert.present();
  }

  getBluetoothDeviceData(bluetooth_name: string){
    this.Bluetooth_Device_List.forEach(element => {
      if(element.name ==bluetooth_name ){
        this.SelectedPrinter = element
      }
      
    });
  }
}

  

bluetooth provider class

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import {AlertController, LoadingController, ToastController } from 'ionic-angular';
import { BluetoothSerial } from '@ionic-native/bluetooth-serial';
import {MutableBuffer} from 'mutable-buffer';

/**
 * RGB interface
 */
interface IRGB {
  r: number;
  g: number;
  b: number;
  a: number;
}

@Injectable()
export class PrintProvider {

  buff=new MutableBuffer(1000,1000);
  
  constructor(public http: HttpClient, private btSerial:BluetoothSerial, 
    private alertCtrl:AlertController , public loadingCtrl: LoadingController, public toastCtrl: ToastController) {
    
  }

  searchBt()
  {
    return this.btSerial.list();
  }

  connectBT(bluetooth_address)
  {
    return this.btSerial.connect(bluetooth_address);
  }  

  disconnectBT(){
    this.btSerial.disconnect();
  }

  formatPrint(bluetooth_address){
    var temp_date = new Date();
    var year = temp_date.getFullYear();
    var month = temp_date.getMonth().toString();
    var day = temp_date.getDate();

    var hour = temp_date.getHours();
    var minutes = temp_date.getMinutes();
    var period = "AM"

    if(hour > 12){
      var result = Number.parseInt(hour.toString()) - 12
      hour =  result
      period = "PM"
    }

    var time = hour + ":" + minutes +" " + period

    var todayDate = month + "/" + day + "/" + year + " " + time
   
    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_CT);
    this.buff.write(this.Command.TEXT_FORMAT.TXT_BOLD_ON);
    this.buff.write(this.Command.TEXT_FORMAT.TXT_2HEIGHT);
    this.buff.write(this.Command.TEXT_FORMAT.TXT_2WIDTH);

    this.buff.write("PCG Cellphone Shop");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    
    this.buff.write(this.Command.TEXT_FORMAT.TXT_NORMAL);
    this.buff.write(this.Command.TEXT_FORMAT.TXT_BOLD_OFF);

    this.buff.write("Plaza Burgos, Guagua, Pampanga");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF); //2 lines
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_BOLD_OFF);
    this.buff.write(this.Command.TEXT_FORMAT.TXT_BOLD_OFF);
    this.buff.write(this.Command.TEXT_FORMAT.TXT_FONT_A);

    this.buff.write("Smart Padala No.");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write("5577-5194-0426-6109");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    
    this.buff.write("5577-5194-0426-7109");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write("0999-3209009");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF); //2 lines
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);
/////////////////////////////////////////////////////////////
    this.buff.write("Cashier: PCG Sales POS");

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write("POS: SP POS 1");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF); //2 lines
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);

    this.buff.write("Customer: Nora B. Beiza");

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write("09430359637");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write("------------------------------------------------");
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);

    this.buff.write("Receive - Smart Padala:   ");
    this.buff.write("2,000.00");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);
    this.buff.write("1 x 2,000.00");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);
    this.buff.write("20Jan 10:19: Received P2,000.00 with P23.00 commission from 09393965558 to PCG LA.LIBRE ang pag-claim! Ref:174813715fdf Bal:P16,297.84");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);
    this.buff.write("03. 1,500.01 to 2,000 -> ");
    this.buff.write("0.00");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);
    this.buff.write("Receive Charge");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);
    this.buff.write("1 x 0.00");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write("------------------------------------------------");
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);
    this.buff.write(this.Command.TEXT_FORMAT.TXT_BOLD_ON);

    this.buff.write("Total:   ");
    this.buff.write("2,000.00");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_LT);
    this.buff.write(this.Command.TEXT_FORMAT.TXT_BOLD_OFF);
    this.buff.write(this.Command.TEXT_FORMAT.TXT_NORMAL);

    this.buff.write("Cash:   ");
    this.buff.write("2,000.00");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write("------------------------------------------------");
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
/////////////////////////////////////////////////////////////

    this.buff.write(this.Command.TEXT_FORMAT.TXT_ALIGN_CT);
    this.buff.write("Thank you for choosing Smart Padala!");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(this.Command.TEXT_FORMAT.TXT_BOLD_ON);
    this.buff.write("Bald Puppies Solutions Inc.");
    this.buff.write(this.Command.TEXT_FORMAT.TXT_BOLD_OFF);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF); 
    this.buff.write("2nd Floor, Traders Square Building");
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write("P. Burgos Street");
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write("Naga, Camarines Sur 4400");
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write("(054) 881 1748");

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);
    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.buff.write(todayDate);

    this.buff.write(this.Command.FEED_CONTROL_SEQUENCES.CTL_LF);

    this.presentLoading();
    let xyz=this.connectBT(bluetooth_address).subscribe(data=>{
      this.btSerial.write(this.buff.buffer).then(dataz=>{
        this.buff.flush();
        this.buff.write(this.Command.HARDWARE.HW_INIT)

       this.informationtoast("Print successfully!");

        xyz.unsubscribe();
      },errx=>{
        this.buff.flush();
        this.buff.write(this.Command.HARDWARE.HW_INIT)
        this.errorToast("Print failed.");

      });
      },err=>{
        this.buff.flush();
        this.buff.write(this.Command.HARDWARE.HW_INIT)
        this.disconnectBT();
        this.errorToast("Connection error.");
      });
  }

  Command={
    LF: '\x0a', //Line feed for new lines
    EOL: '\n', //end of line
    FEED_CONTROL_SEQUENCES: {
        CTL_LF: '\x0a', // Print and line feed
        CTL_FF: '\x0c', // Form feed
        CTL_CR: '\x0d', // Carriage return
        CTL_HT: '\x09', // Horizontal tab
        CTL_VT: '\x0b', // Vertical tab
    },
    LINE_SPACING: {
        LS_DEFAULT: '\x1b\x32',  //Spacing
        LS_SET: '\x1b\x33'  //Spacing
    },
    HARDWARE: {
        HW_INIT: '\x1b\x40', // Clear data in buffer and reset modes
        HW_SELECT: '\x1b\x3d\x01', // Printer select
        HW_RESET: '\x1b\x3f\x0a\x00', // Reset printer hardware
    },
    CASH_DRAWER: {
        CD_KICK_2: '\x1b\x70\x00', // Sends a pulse to pin 2 []
        CD_KICK_5: '\x1b\x70\x01', // Sends a pulse to pin 5 []
    },
    MARGINS: {
        BOTTOM: '\x1b\x4f', // Fix bottom size
        LEFT: '\x1b\x6c', // Fix left size
        RIGHT: '\x1b\x51', // Fix right size
    },
    PAPER: {
        PAPER_FULL_CUT: '\x1d\x56\x00', // Full cut paper
        PAPER_PART_CUT: '\x1d\x56\x01', // Partial cut paper
        PAPER_CUT_A: '\x1d\x56\x41', // Partial cut paper
        PAPER_CUT_B: '\x1d\x56\x42', // Partial cut paper
    },
    TEXT_FORMAT: {
        TXT_NORMAL: '\x1b\x21\x00', // Normal text
        TXT_2HEIGHT: '\x1b\x21\x10', // Double height text
        TXT_2WIDTH: '\x1b\x21\x20', // Double width text
        TXT_4SQUARE: '\x1b\x21\x30', // Double width & height text

        TXT_CUSTOM_SIZE: function(width, height) { // other sizes
            var widthDec = (width - 1) * 16;
            var heightDec = height - 1;
            var sizeDec = widthDec + heightDec;
            return '\x1d\x21' + String.fromCharCode(sizeDec);
        },

        TXT_HEIGHT: {
            1: '\x00',
            2: '\x01',
            3: '\x02',
            4: '\x03',
            5: '\x04',
            6: '\x05',
            7: '\x06',
            8: '\x07'
        },
        TXT_WIDTH: {
            1: '\x00',
            2: '\x10',
            3: '\x20',
            4: '\x30',
            5: '\x40',
            6: '\x50',
            7: '\x60',
            8: '\x70'
        },

        TXT_UNDERL_OFF: '\x1b\x2d\x00', // Underline font OFF
        TXT_UNDERL_ON: '\x1b\x2d\x01', // Underline font 1-dot ON
        TXT_UNDERL2_ON: '\x1b\x2d\x02', // Underline font 2-dot ON
        TXT_BOLD_OFF: '\x1b\x45\x00', // Bold font OFF
        TXT_BOLD_ON: '\x1b\x45\x01', // Bold font ON
        TXT_ITALIC_OFF: '\x1b\x35', // Italic font ON
        TXT_ITALIC_ON: '\x1b\x34', // Italic font ON

        TXT_FONT_A: '\x1b\x4d\x00', // Font type A //normal font
        TXT_FONT_B: '\x1b\x4d\x01', // Font type B //small font
        TXT_FONT_C: '\x1b\x4d\x02', // Font type C //normal font

        TXT_ALIGN_LT: '\x1b\x61\x00', // Left justification
        TXT_ALIGN_CT: '\x1b\x61\x01', // Centering
        TXT_ALIGN_RT: '\x1b\x61\x02', // Right justification
    },
    BARCODE_FORMAT: {
        BARCODE_TXT_OFF: '\x1d\x48\x00', // HRI barcode chars OFF
        BARCODE_TXT_ABV: '\x1d\x48\x01', // HRI barcode chars above
        BARCODE_TXT_BLW: '\x1d\x48\x02', // HRI barcode chars below
        BARCODE_TXT_BTH: '\x1d\x48\x03', // HRI barcode chars both above and below

        BARCODE_FONT_A: '\x1d\x66\x00', // Font type A for HRI barcode chars
        BARCODE_FONT_B: '\x1d\x66\x01', // Font type B for HRI barcode chars

        BARCODE_HEIGHT: function(height) { // Barcode Height [1-255]
            return '\x1d\x68' + String.fromCharCode(height);
        },
        // Barcode Width  [2-6]
        BARCODE_WIDTH: {
            1: '\x1d\x77\x02',
            2: '\x1d\x77\x03',
            3: '\x1d\x77\x04',
            4: '\x1d\x77\x05',
            5: '\x1d\x77\x06',
        },
        BARCODE_HEIGHT_DEFAULT: '\x1d\x68\x64', // Barcode height default:100
        BARCODE_WIDTH_DEFAULT: '\x1d\x77\x01', // Barcode width default:1

        BARCODE_UPC_A: '\x1d\x6b\x00', // Barcode type UPC-A
        BARCODE_UPC_E: '\x1d\x6b\x01', // Barcode type UPC-E
        BARCODE_EAN13: '\x1d\x6b\x02', // Barcode type EAN13
        BARCODE_EAN8: '\x1d\x6b\x03', // Barcode type EAN8
        BARCODE_CODE39: '\x1d\x6b\x04', // Barcode type CODE39
        BARCODE_ITF: '\x1d\x6b\x05', // Barcode type ITF
        BARCODE_NW7: '\x1d\x6b\x06', // Barcode type NW7
        BARCODE_CODE93: '\x1d\x6b\x48', // Barcode type CODE93
        BARCODE_CODE128: '\x1d\x6b\x49', // Barcode type CODE128
    },
    CODE2D_FORMAT: {
        TYPE_PDF417: '\x1b\x5a\x00',
        TYPE_DATAMATRIX: '\x1b\x5a\x01',
        TYPE_QR: '\x1b\x5a\x02',
        CODE2D: '\x1b\x5a',
    },
    IMAGE_FORMAT: {
        S_RASTER_N: '\x1d\x76\x30\x00', // Set raster image normal size
        S_RASTER_2W: '\x1d\x76\x30\x01', // Set raster image double width
        S_RASTER_2H: '\x1d\x76\x30\x02', // Set raster image double height
        S_RASTER_Q: '\x1d\x76\x30\x03', // Set raster image quadruple
    },
    BITMAP_FORMAT: {
        BITMAP_S8: '\x1b\x2a\x00',
        BITMAP_D8: '\x1b\x2a\x01',
        BITMAP_S24: '\x1b\x2a\x20',
        BITMAP_D24: '\x1b\x2a\x21'
    },
    GSV0_FORMAT: {
        GSV0_NORMAL: '\x1d\x76\x30\x00',
        GSV0_DW: '\x1d\x76\x30\x01',
        GSV0_DH: '\x1d\x76\x30\x02',
        GSV0_DWDH: '\x1d\x76\x30\x03'
    }
};

  presentLoading() {
   const loader = this.loadingCtrl.create({
      content: "Please wait...",
   });
   loader.present();
  }

  informationtoast(textMessage: string) {
    const toast = this.toastCtrl.create({
      message: textMessage,
      duration: 3000,
      cssClass: 'information-toast'

    });
    toast.present();
  }

  errorToast(textMessage: string) {
    const toast = this.toastCtrl.create({
      message: textMessage,
      duration: 3000,
      cssClass: 'error-toast'
    });
    toast.present();
  }
}

Posts: 1

Participants: 1

Read full topic

How to show menu button when i push page by navCtrl?

$
0
0

@_Ali94 wrote:

As a title, I need a way to show menu button in the pushed page but I don’t know how

It shows in root pages but its not for pushed pages.

Any helps please ?

Posts: 1

Participants: 1

Read full topic

I cant get my ionic app to open in iOS emulator

$
0
0

@ejerskov wrote:

My new ionic app won’t run in the iOS emulator.

Its a fresh install of ionic and Xcode, these are my steps:

npm install -g ionic

ionic start myApp tabs

ionic cordova platform add ios

ionic cordova build ios

ionic cordova emulate ios

Then I get the following error:

No target specified for emulator. Deploying to undefined simulator
/localhost/myApp/platforms/ios/build/emulator/MyApp.app/Info.plist
file not found.

According to this thread (Fresh Ionic Fails to Emulate iOS 12 - Info.plist file not found) it should work with the following command:

ionic cordova emulate ios -- --buildFlag="-UseModernBuildSystem=0"

But then I get the following error:

No target specified for emulator. Deploying to undefined simulator
Device type “com.apple.CoreSimulator.SimDeviceType.undefined” could not be found.

And then according to this thread (Issues starting iOS simulator from CLI) it should work by updating ios-sim like this:

cd platforms/ios/cordova && npm install ios-sim@latest

But I still get the following error:

No target specified for emulator. Deploying to undefined simulator
Device type “com.apple.CoreSimulator.SimDeviceType.undefined” could not be found.

How do I proceed from here?

Ionic:

   ionic (Ionic CLI)             : 4.10.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.1
   @angular-devkit/build-angular : 0.12.4
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.2.4
   @ionic/angular-toolkit        : 1.4.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : ios 5.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 4 other plugins)

System:

   ios-sim : 7.0.0
   NodeJS  : v10.15.1 (/usr/local/bin/node)
   npm     : 6.4.1
   OS      : macOS Mojave
   Xcode   : Xcode 10.1 Build version 10B61

Posts: 1

Participants: 1

Read full topic

(Ionic 4) how to build two menus

Toolbar with horizontal scroll

$
0
0

@rosunad wrote:

Hi everyone,

Didn’t find anything about this with Ionic-v4. I need to make scrollable horizontally a toolbar because of it has several options (see images below)


(Normal view)
image
(Phone view)

My idea is to show two directions marks at both sides and scroll horizontally the options of the toolbar. Each toolbar is a separated component, in this case the code of this one is:

<app-header [title]="title"></app-header>

<ion-toolbar>
    <div style="overflow-x:scroll;overflow:hidden">
        <ion-segment>
            <ion-segment-button value="Clientes" checked>
                Clientes
            </ion-segment-button>
            <ion-segment-button value="Proveedores">
                Proveedores
            </ion-segment-button>
            <ion-segment-button value="Agentes">
                Agentes
            </ion-segment-button>
            <ion-segment-button value="Almacenes">
                Almacenes
            </ion-segment-button>
            <ion-segment-button value="Articulos">
                Artículos
            </ion-segment-button>
            <ion-segment-button value="Usuarios">
                Usuarios
            </ion-segment-button>
        </ion-segment>
    </div>
</ion-toolbar>

Hope someone got an idea about this.

Thank you

Posts: 1

Participants: 1

Read full topic

How to do a simply Logout on Ionic 4 with Firestore?

$
0
0

@Manel00 wrote:

Hi everyone!

I’m looking for a simply code and useful to do a logout with these technologies, thank you so much, i’m trying to avoid to use AngularFirestoreAuth and kind of…

Posts: 1

Participants: 1

Read full topic


Boolean for loading different data

$
0
0

@aligassan wrote:

l am working on ionic 4 project. My project is getting data json from url content flights schedules . Everything is okay , but l want to use button boolean when users click on button show to users the flights schedules for yesterday . l don`t want to create another page for holding flights schedules for yesterday l want used in same page and same code . l did like this but when l click on button he is not load any information shows for flights schedules yesterday

  Loadearlierflights : boolean = true;

      async getData() {


        const loading = await this.loadingController.create({
          message: 'Loading'
        });
        await loading.present();

          /// flights details for today ///

        if (this.Loadearlierflights=true) {
          this.http.get('xxxxxxx/airport.json?code=bsr', {}, {})
          .then(data => {

            this.test = JSON.parse(data.data);
            const parsed = JSON.parse(data.data);
            this.items = parsed.pluginData.schedule.arrivals.data;
            loading.dismiss()


            console.log(this.items)

          }), err=>{
            this.test =err
            loading.dismiss()
          } 

                   /// flights details for yesterday ///

        }else if (this.Loadearlierflights=false) {
          this.http.get('xxxxxxxx/airport.json?code=bsr&page=-1', {}, {})
          .then(data => {

            this.test = JSON.parse(data.data);
            const parsed = JSON.parse(data.data);
            this.items = parsed.pluginData.schedule.arrivals.data;
            loading.dismiss()


            console.log(this.items)


          }), err=>{
            this.test =err
            loading.dismiss()
          }

        }

html

<ion-button shape="round" (click)="getData()">load earlier flights</ion-button>

any ideas please ?

Posts: 4

Participants: 2

Read full topic

Gif animation work just once

$
0
0

@safaAlshaarri wrote:

hi everyone
i have app where i am showing a gif img, the problem that when it shows the gif first time the animation played one when i go to another pages then back to the page the have the gif it doesn’t animate again how i can fix that

Posts: 1

Participants: 1

Read full topic

Map is loaded but Polyline are not draw in the map in ionic3?

$
0
0

@RomnEmpire wrote:

Hi
I am working in an App in Ionic 3 that shows current position in the map as well click start track button we have to add polyline between the lat and lang.i know there are some ways to draw polylines my idea is to extract the lat, long coordinates of the marker, save them in an array and then set that as a “path” to draw the Polyline but I’m having problems polylines are not drawn in the map. check our below code

loadMap(){

    this.geolocation.getCurrentPosition().then((position) => {
      let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
      let mapOptions = {
        center: latLng,
        position: latLng,
        zoom: 15,

        mapTypeId: google.maps.MapTypeId.ROADMAP
      }

      this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
      this.addMarker();

    }, (err) => {
      console.log(err);
    });
  }

  startTracking() {

    this.isTracking = true;
    this.trackedRoute = [];
 
    this.positionSubscription = this.geolocation.watchPosition()
      .pipe(
        filter((p) => p.coords !== undefined) //Filter Out Errors
      ).subscribe(data => {
        setTimeout(() => {
          this.trackedRoute.push({ lat: data.coords.latitude, lng: data.coords.longitude });
          this.redrawPath(this.trackedRoute);
        }, 0);
      });
  }
 
  redrawPath(path) {
    if (this.currentMapTrack) {
      this.currentMapTrack.setMap(null);
    }
 
    if (path.length > 1) {
      this.currentMapTrack = new google.maps.Polyline({
        path: path,
        geodesic: true,
        strokeColor: '#ff00ff',
        strokeOpacity: 1.0,
        strokeWeight: 3
      });
      this.currentMapTrack.setMap(this.map);
    }
  }

Posts: 1

Participants: 1

Read full topic

Ion-menu-button element is a unknown element

$
0
0

@marvtdawson72 wrote:

Hi, I just downloaded the latest Ionic package (beta 5) and added a new component called “CustomerPage”. I am getting a error that said Ionic does not recognized a ionic element on compile. I tried adding Custom_Element_Schema to the module and got nothing. Is anyone else experiencing this type of problem with Ionic and Angular?

Posts: 1

Participants: 1

Read full topic

Ng-bind-html not working in ionic

$
0
0

@fahd123 wrote:

<ion-card *ngFor="let act of actualite ">
        <ion-card-header>
          <ion-img src='https://www.proweb.ma/ten-pass/photos-actualite/small/{{act.photo}}'></ion-img>
          <ion-card-subtitle>{{act.lib1}}</ion-card-subtitle>
          <ion-card-title>{{act.sub_title}}</ion-card-title>
        </ion-card-header>
      
        <ion-card-content>
        <ion-p ng-bind-html='{{act.text1}}'></ion-p>
        </ion-card-content>
      </ion-card>

Posts: 1

Participants: 1

Read full topic

Cordova-plugin-facebook4 Facebook login not opening on iOS

$
0
0

@almen21 wrote:

Hello,

I have a problem with cordova-plugin-facebook4 (https://github.com/jeduan/cordova-plugin-facebook4) on iOS devices. After following the installation procedure as indicated in the documentation (“iOS Guide”) and configuring correctly the app in the Facebook Developer Console,
when I click on my Facebook login button nothing happens. The XCODE console outputs the following error:

2019-02-15 17:22:58.678937+0100 HelloCordovaApp[59179:1228209] Logging in with CORDOVA ... 2019-02-15 17:22:58.692742+0100 HelloCordovaApp[59179:1228209] Checking login status: unknown 2019-02-15 17:22:58.692947+0100 HelloCordovaApp[59179:1228209] Performing Fb login ... 2019-02-15 17:22:58.693087+0100 HelloCordovaApp[59179:1228209] Starting login 2019-02-15 17:22:58.693271+0100 HelloCordovaApp[59179:1228209] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> Permissions should each be specified in separate string values in the array. 2019-02-15 17:22:58.694627+0100 HelloCordovaApp[59179:1228209] Client application failed to make a policy decision via WebPolicyDecisionListener, using defaultPolicy 2

The app I developed is written in AngularJs and it’s wrapped using Cordova.
What could it be? On Android devices it works perfectly…
Here’s the code that’s executed when user clicks on my Facebook login button:

function fbLoginButtonClick(){
	console.log('Logging in with CORDOVA ...');
	facebookConnectPlugin.getLoginStatus(_fbLoginStatusSuccess, _fbLoginStatusError);
}

////////

function _fbLoginStatusSuccess(response) {
	var responseStatus = response.status;
	console.log('Checking login status: ', responseStatus);
	if (responseStatus === 'connected') {
	  _fbLoginSuccess();
	} else if (responseStatus !== null) {
	  _doFbLogin();
	} else {
	  handleFacebookError(responseStatus);
	}
 }

function _fbLoginStatusError(error) {
	handleFacebookError(error);
}   
 
function _doFbLogin() {
	console.log('Performing Fb login ...');
	facebookConnectPlugin.login(['email, public_profile'], _fbLoginSuccess, _fbLoginError);
}

function _fbLoginSuccess(result) {
	console.log('Fb API: getting user data ...');
	facebookConnectPlugin.api('/me?fields=id,name,first_name,last_name,email', ['email', 'public_profile'], _fbApiSuccess, _fbApiError);
}

function _fbLoginError(error) {
	handleFacebookError(error);
}  

function _fbApiSuccess(userData) {
	alert('User Authenticated!!');
	//redirect to admin page
}

function _fbApiError(error) {
	handleFacebookError(error);
}

function handleFacebookError (error) {
  if(error){
    console.log(error);
  }
}

And this is the configuration on my config.xml file:

<plugin name="cordova-plugin-facebook4" spec="4.2.1">
    <variable name="APP_ID" value="************" />
    <variable name="APP_NAME" value="HelloCordovaApp" />
    <variable name="FACEBOOK_HYBRID_APP_EVENTS" value="false" />
    <variable name="FACEBOOK_ANDROID_SDK_VERSION" value="4.40.0" />
</plugin>

Posts: 1

Participants: 1

Read full topic

Sending ion range results to database

$
0
0

@quotennial wrote:

I’m using ion range to get a response, after clicking a button I would like to send the value the ion range is currently set at to a database, what method is best to do this using typescript I assume? The current HTML:

<div class="slider_position">
    <ion-range min="1" max="5" start="3" [(ngModel)]="surveyRange" pin = "true" color="raptor2" snaps="true">
      <ion-label range-left>1</ion-label>
      <ion-label range-right>5</ion-label>
    </ion-range>
</div>

Thank you! :slightly_smiling_face:

Posts: 1

Participants: 1

Read full topic


How do I set the fixed background image in my Ionic 4 app?

$
0
0

@dungeonbaba wrote:

I am using Ionic 4 . On my Login Page whenever keyboard is pressed, background image scrolls up. I found no workaround until now.

I applied below css to ion-content :

ion-content{
 --background: #fff url('/assets/img/bigscren.jpg') no-repeat center center / cover !important;
 --background-size: cover !important;
 --background-attachment: fixed;
}

This is my front page:

<ion-content padding>
//My Content
</ion-content>

I also applied fixed attribute to ion-content (from latest ionic doc) but that also not working.

Please help me out. Thanks!

Posts: 1

Participants: 1

Read full topic

Ionic Market Updates

$
0
0

@ahmadao wrote:

Why there are no updates to Ionic Market, it seems Ionic team forgot about it, although I believe it is great opportunity for developers to help other people and monetize.

Posts: 1

Participants: 1

Read full topic

Use HTML in ionic4 Loading

$
0
0

@distante wrote:

With Ionic 3 I was able to do this:

const loader = this.loadingCtrl.create({
        message: this.sanitizer.bypassSecurityTrustHtml(loadingText) as string,
        spinner: 'dots'
});

or

loader.message = this.sanitizer.bypassSecurityTrustHtml(loadingText) as string,

And use there custom HTML inside Ionic Loading Component. With Ionic4 I just get an empty Loading. Is there a way to use HTML in the Loading Component with Ionic4 ?

Edit: when I append some text after the Safe HTML I get after the bypassSecurity i see this

SafeValue must use [property]=binding: 

Edit 2: In the official docs says

and any optional HTML can be passed in the content property.

But there is no content property in HTMLIonLoadingElement

Posts: 1

Participants: 1

Read full topic

Help ionic 3 build ios cannot get data from firebase

$
0
0

@Heolun wrote:

Hi everyone, i build my app on ios device, i run app on browser ok, it got data from firebase. Then i used xcode build and run on my iphone 5s, build successed, and running, app load backgroud, image local but not get data from firebase. So i hope you help me solve this problem

Posts: 1

Participants: 1

Read full topic

How Can i Change Button to 2 buttons onClick

Viewing all 48980 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>