Quantcast
Channel: Ionic Forum - Latest topics
Viewing all 70435 articles
Browse latest View live

Path problem after building an Ionic web application

$
0
0

@trohde wrote:

Hi all,

I’m new to Ionic development and have just finished an application which I want to build and deploy as a normal web application. When I try to build it I struggle with a path problem. The easiest way to see my problem is when you create a new project.

ionic start my-app sidemenu

Everything is okay when I run it in the browser.

ionic serve

With no changes I build it for production.

ionic build --prod

When I copy the content of the www folder into a subfolder on my webserver (e.g. mobile) it fails to start because it tries to find the css and js files in the root of the webserver.

On https://github.com/ionic-team/ionic-cli/issues/3600 I found that I have to set the base-href (this seems to be undocumented on ionic build --help).

ionic build --prod -- --base-href /mobile/

This works better and the application is running but it still tries to find the assets in the assets folder below the root folder (/htdocs/assets/ instead /htdocs/mobile/assets/. In the example app it’s only the file shapes.svg but in my app I have some more images and the translation files there.

Is there a way to set something like “–relative-paths” when building the application? Or is there another way?

Some additional information:
Ionic CLI : 5.2.1
Ionic Framework : @ionic/angular 4.6.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1

Posts: 1

Participants: 1

Read full topic


Dynamic change rootPage on inic 4

$
0
0

@durvilchat wrote:

Hello guests , How are you Please I need you I would like to know how to change a dynamic face the root Page sur ionic 4 Thank you

Posts: 1

Participants: 1

Read full topic

How To integrate MQTT in ionic 4 project

Push json data into array

$
0
0

@Tubiss wrote:

public products:any=;

loadPeople(){
this.remoteService.load()
.then(data => {
console.log(data);
this.people = data;
this.people.sort((x,y) => new Date(x.start_time).getTime() - new Date(y.start_time).getTime());
this.products=this.people;

});

when ı write the this.products[2] its giving error “2” "is not defined. I just make push data in to products array

Posts: 1

Participants: 1

Read full topic

ElementRef not finding DOM node with MutationObserver

$
0
0

@ctfrancia wrote:

I am trying to scroll to the bottom of the view when a new message comes in. However, it is not finding it and not scrolling down and I cannot find any solution to it. I was following a ionic-3 version of this however, the way that we reference the Dom nodes has changed??

<ion-content #content>
  <ng-container *ngIf="messages$.length; else loading">
    <ion-grid>
      <ion-row *ngFor="let message of messages$">
        <ion-col
          *ngIf="id === message.id"
          size="9"
          offset="3"
          class="message my-message"
          [ngStyle]="{ background: message.isUrgent ? 'var(--ion-color-danger)' : 'var(--ion-color-primary)' }"
        >
<!-- hiding  more divs for brevity -->
        </ion-col>
      </ion-row>
    </ion-grid>
  </ion-content>

component.ts

  private mutationObserver: MutationObserver;

  @ViewChild(IonContent) private content: IonContent;
  @ViewChild(IonCol, { read: ElementRef }) private chatList: ElementRef
//note, above I have tried, IonList/Row/Col/Grid

  public ngAfterViewInit(): void {
    this.mutationObserver = new MutationObserver((mutations: MutationRecord[]): void => {
      console.log('here', mutations); //<--never in console
      this.content.scrollToBottom();
    });
    this.mutationObserver.observe(this.chatList.nativeElement, {
      childList: true,
    });
  }

any help greatly appreciated, thanks

Posts: 1

Participants: 1

Read full topic

Loading data from localbrowser DB to ion-select isn't working

$
0
0

@stephenmonro wrote:

Hello all.
I’ve just about given up on how to make this work. I don’t know what else to do now except ask for help as I’ve been working on this for days.

I’m using ionic-v4.

What I’m trying to do is have a settings page be able to load and save values. I plan on storing this in local storage, and numeral values and other pages in my app are working where I’m just using a standard INPUT tag, however using an ion-select, it doesn’t work at all. All I seem to get is error messages - if a value in the local browser db exists. If a value in the dB doesn’t exist, it’ll move to the next ion-select, and they show an error.

I know this error is common to many people as I’ve been researching this and open a hundred links, but it’s rather complicated.

This is the frustrating error I get:

ERROR Error: “ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: ‘model: fueltype’. Current value: ‘model: LPG’.”
Angular 7
View_SettingsPage_1 SettingsPage.html:32
Angular 27
RxJS 5
Angular 11
ERROR CONTEXTObject { view: {…}, nodeIndex: 36, nodeDef: {…}, elDef: {…}, elView: {…} }

My HTML code (with a shorten list of options) is:

<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start">
          <ion-menu-button></ion-menu-button>
        </ion-buttons>
        <ion-title>
          Settings
        </ion-title>
      </ion-toolbar>
</ion-header>

<ion-content *ngIf="displayMain">
    <ion-card class="welcome-card"> 
        <ion-card-header>
          <ion-card-subtitle>Settings</ion-card-subtitle>
          <ion-card-title>Adjust as required.</ion-card-title>
        </ion-card-header>
        <ion-card-content>
          <p>Make the changes required for the default settings of the app.</p>
        </ion-card-content>
      </ion-card>
       
      <ion-grid padding>
          <ion-row>
              <ion-col col-12>   
                <ion-list>
                    <ion-label>App Settings</ion-label>
                    <ion-item>
                      <ion-label>Fuel Type</ion-label>
                      <br>
                      <ion-select  name="fueltype" id="fueltype" [(ngModel)]="fueltype"  value="{{fueltypeVal}}" okText="Save" cancelText="Cancel"> 
                        <ion-select-option value="91Petrol">91 Petrol</ion-select-option>
                        <ion-select-option value="LPG">LPG</ion-select-option>
                        <ion-select-option value="Gasoline">Gasoline</ion-select-option>
                        <ion-select-option value="Diesel">Diesel</ion-select-option> 
                      </ion-select>
                    </ion-item> 
                  </ion-list> 
              </ion-col>
          </ion-row> 

          <ion-row>
            <ion-col col-12>
                <ion-list>
                  <ion-label>Amount of Fuel </ion-label>
                  <br>
                  <ion-input class="pricenumbers" id="fuelamount" [(ngModel)]="fuelamount" type="number"></ion-input>
                </ion-list>
              </ion-col>
          </ion-row>

          <ion-row>
              <ion-col col-12>
                  <ion-list>
                    <ion-label>Country </ion-label>
                    <br>
                    <ion-select  name="country" id="country" [(ngModel)]="country"  value="{{countryVal}}" okText="Save" cancelText="Cancel">  
                        <ion-select-option value="cents">Cents</ion-select-option>
                        <ion-select-option value="dollars">Dollars</ion-select-option>
                      </ion-select>
                  </ion-list>
                </ion-col>
            </ion-row>

            <ion-row>
                <ion-col col-12>
                    <ion-list>
                      <ion-label>Measurement</ion-label>
                      <br>
                      <ion-select  name="measurement" id="measurement" [(ngModel)]="measurement"  value="{{measurementVal}}" okText="Save" cancelText="Cancel"> 
                          <ion-select-option value="litres">Litres</ion-select-option>
                          <ion-select-option value="gallons">Gallons</ion-select-option>
                        </ion-select>
                    </ion-list>
                  </ion-col>
              </ion-row>
 
            <ion-row>
                <ion-col col-12>
                    <button ion-button (click) = "saveSettings()" icon-start large round color="dark" style="width:100%; font-size: 3em;">
                        <ion-icon name="star" hidden></ion-icon>
                        Save settings
                    </button> 

                    <button hidden ion-button (click) = "loadSettings()" icon-start large round color="dark" style="width:100%; font-size: 3em;">
                      <ion-icon name="star" hidden></ion-icon>
                      Load settings
                  </button> 
                </ion-col>
            </ion-row> 
          
      </ion-grid> 
</ion-content>

My TS code is:


import { Component, OnInit } from '@angular/core';
import { Storage } from '@ionic/storage';  


@Component({
  selector: 'app-settings',
  templateUrl: './settings.page.html',
  styleUrls: ['./settings.page.scss'],
})
export class SettingsPage implements OnInit {
  

  constructor(private storage: Storage 
    ) { }

  fueltype: any = "fueltype";
  fueltypeVal: any = "Litres";
  fueltemp: any;
  displayMain: boolean;
  countryVal: any  = 0;
  measurementVal: any = 0;
  country: any = 0;
  measurement: any; 
  fuelamount: number = 50;
 

 ionViewWillEnter ()
 { 
  this.displayMain = false; 
  setTimeout(() => { 
    this.getSettings(); 
  },0);  
  this.displayMain = true;
 }

 ngOnInit()
  {    
  }  

  async getSettings()
  {
      // set a key/value   
        this.storage.get('fueltype').then((val) => { 
        this.fueltypeVal = val; 
 
        console.debug (this.fueltypeVal); 
      });  

        this.storage.get('fuel').then((val) => { 
        this.fuelamount = val;
        console.debug (this.fuelamount);
      });  

        this.storage.get('country').then((val) => { 
        this.countryVal = val; 
        console.debug (this.countryVal); 
      });  

       this.storage.get('measurement').then((val) => { 
        this.measurementVal = val;
        console.debug (this.measurementVal);
      });  

      console.debug (this.fueltype);
      console.debug (this.fuelamount);
      console.debug (this.country);
      console.debug (this.measurement); 
      console.debug (this.fueltypeVal);
      console.debug (this.fuelamount);
      console.debug (this.countryVal);
      console.debug (this.measurementVal);  

  }

  saveSettings()
  {
    this.storage.set('fueltype', this.fueltype);
    this.storage.set('fuel', this.fuelamount);   
    this.storage.set('country', this.country);
    this.storage.set('measurement', this.measurement);  
    console.debug (this.fueltype);
    console.debug (this.fuelamount);
    console.debug (this.country);
    console.debug (this.measurement); 
    console.debug (this.fueltypeVal);
    console.debug (this.fuelamount);
    console.debug (this.countryVal);
    console.debug (this.measurementVal); 
  }

  loadSettings()
  {
    this.getSettings();
  }

}

I don’t think I’m doing anything strange, because it works fine on the standard “Input” Tag. Just not these select options. Any thoughts? Am I approaching this in the wrong way?
Thanks in advance.
-Steve

Posts: 1

Participants: 1

Read full topic

Closing ionic 4 app problem

Get data from storage before page is load


Camera preview problem

$
0
0

@pinoyprogs wrote:

Hi sir good day.
I have problem in my camera preview.

When I start my camera. my camera preview don’t show what camera.
instead it shows my other modal.

here are some of my snippets in TS.

start(): void {

    this.picture = "";
    this.cameraPreview.startCamera({
        x: 0,
        y: 0,
        width: window.screen.width,
        height: window.screen.height,
        camera: 'rear',
        tapPhoto: true,
        previewDrag: true,
        toBack: true,
        alpha: 1
    }).then(
        (res) => {
            console.log(res)
        },
        (err) => {
            console.log(err)
        });
};

Posts: 1

Participants: 1

Read full topic

Preflight response is not successful in Capacitor iOS platform

$
0
0

@Pujy25 wrote:

Hi everyone!
I have a problem when I am trying to do a Http call using capacitor (iOS platform).
The error is the following:
[Error] XMLHttpRequest cannot load https://… due to access control checks.
Failed to load resource: Preflight response is not successful

I think that the issue is related to the origin, in that case is: capacitor://localhost, so I included that origin in the backend side as allowed origin but it is still not working…

I have the service hosted in Azure Cloud and when I am trying to set the cors rules it doesn’t allow origins starts with capacitor://… only allows http:// or https://.

Thanks in advance!

Posts: 1

Participants: 1

Read full topic

How to delete the certain data from array

$
0
0

@ice174 wrote:

I am new in ionic 4. I am doing shopping cart function. I want to delete the selected item. But it delete like pop function not delete the certain item. I have follow this tutorial : https://devdactic.com/dynamic-ionic-4-slides/

In service ts I am using this function
then
Cart.page.ts

onDeleteItem(i) {
const index = this.selectedItems.indexOf(i);
if (index > -1) {
this.cartServ.deleteFromCart(index);
this.selectedItems.splice(index, 1);
console.log(this.selectedItems);
}
this.total = this.selectedItems.reduce((a, b) => a + (b.count * b.price), 0);
}

Cart.service

addToCart(product) {
    this.cartService.addProduct(product);
  }


deleteFromCart(i) {
console.log(i);
if (i === 0) {
this.cart.shift();
} else {
this.cart.splice(i, 1);
}
}

Anyone can help me?

Posts: 1

Participants: 1

Read full topic

Difference between ionic 4 and ionic 5

$
0
0

@premktr wrote:

today when I created a new ionic project my ionic version has changed to V5.intially I worked with ionic4.are there any big differences between them?

Posts: 1

Participants: 1

Read full topic

Error "Google is not defined" after target API level 28+"

$
0
0

@Weihang wrote:

after I change 27 to 28

<preference name="android-targetSdkVersion" value="28" />

Google Map throws this error
ERROR Error: Uncaught (in promise): ReferenceError: google is not defined

Posts: 1

Participants: 1

Read full topic

Starter Template Pack for WordPress Multisite

$
0
0

@mark_bigrock wrote:

Hi

Does anyone have a recommendation for a starter template/pack for an Ionic app and WordPress multisite?

Thanks Mark

Posts: 1

Participants: 1

Read full topic

Ionic1 iOS

$
0
0

@Siva_LMS_IONIC wrote:

When I re-run the application. Application network and required java script files don’t called and its working after 10 mins. Here I have included my Device Info

Framework : ionic1 cordova
Phonegap version : 7.0.1
Platform : ios
iOS Build Version : 4.0.1
XCode Version : 10.2.0

Kindly help me out to resolve this issue. Kindly check the below screens.

2 1

Posts: 1

Participants: 1

Read full topic


[ERROR] Updating Cordova and cordova-android to version 8 generates ':app:debugCompileClasspath' error

$
0
0

@YuriGaliza wrote:

Hi everyone!

I updated my Cordova and cordova-android to version 8 and since then I started having an issue.
I simply feel lost on how to solve this, I tried some things but to no avail.

Here’s a screenshot of my issue:

And here’s a screenshot of my environment versions:

version

Posts: 1

Participants: 1

Read full topic

Your app currently targets API level 19 and must target at least API level 26 to ensure that it is built on the latest APIs optimised for security and performance. Change your app's target API level to at least 26

$
0
0

@arcadius wrote:

Hello.

I have just updated my App and set the API level 26.
After uploading it to the Play Store, I realised that my Android 7 phone could not see the app in the app store anymore.

Unfortunately, most of my users are on old devices running Android 4.4, 5.1 and 7 .
So, I have rebuilt my app with API level 19 and when trying to upload, I get the error:

“Your app currently targets API level 19 and must target at least API level 26 to ensure that it is built on the latest APIs optimised for security and performance. Change your app’s target API level to at least 26”

I do understand that Google wants me to support only API Level 26 and above.
My issue is that my clients are using older android 4.4 and 5.1 that I need to support.

Is any one else going through this?

Many thanks.

Posts: 1

Participants: 1

Read full topic

Cant change node version on ionic pro build

$
0
0

@tuscanypub wrote:

i have ionic app which i developed with node 8 version. when i try to upload a hot update i get error because in use on the build nodejs 10. is there any way to solve that issue?

Posts: 1

Participants: 1

Read full topic

AAPT: error: resource android:attr/fontVariationSettings not found for Ionic 3.9.2 and Android 6.4.0

$
0
0

@dalezak-ushahidi wrote:

We started having issues building our Ionic 3.9.2 app for android@6.4.0 getting the error:

AAPT: error: resource android:attr/fontVariationSettings not found.

We’re currently using cordova@8.1.2, ionic@3.20.1 and android@6.4.0.

npm install -g cordova@8.1.2
npm install -g ionic@3.20.1
ionic cordova platform add android@6.4.0 --buildConfig=build.json

Some posts suggest fontVariationSettings added in api level 28, however when I try using android@7.1.4 or android@8.0.0 I start getting different errors like:

error: cannot find symbol 
import com.google.firebase.iid.FirebaseInstanceIdService;

What is the recommended version of cordova and cordova-android to use with ionic-angular@3.9.2?

Which version of Android SDK is supported for Ionic 3.9.2? Should we be targeting 26, 27, or 28?

Something’s got out of sync and now it feels like we’re going down a rabbit hole trying different versions of dependencies to get things compiling again.

Any help or suggestions would be greatly appreciated! :pray:

Posts: 1

Participants: 1

Read full topic

Could not install from "ios" as it does not contain a package.json file

$
0
0

@charleyhankins wrote:

When attempting to run “ionic cordova prepare ios”, I am returned with the following error:

{ Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOLOCAL
npm ERR! Could not install from “ios” as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/southark/.npm/_logs/2019-07-11T20_15_13_124Z-debug.log
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/superspawn.js:135:23)
at ChildProcess.emit (events.js:198:13)
at maybeClose (internal/child_process.js:982:16)
at Socket.stream.socket.on (internal/child_process.js:389:11)
at Socket.emit (events.js:198:13)
at Pipe._handle.close (net.js:606:12)
stderr:
‘npm ERR! code ENOLOCAL\nnpm ERR! Could not install from “ios” as it does not contain a package.json file.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /Users/southark/.npm/_logs/2019-07-11T20_15_13_124Z-debug.log\n’,
code: 1 }
[ERROR] An error occurred while running subprocess cordova.

    cordova platform add ios --save exited with exit code 1.
    
    Re-running this command with the --verbose flag may provide more information.

Posts: 1

Participants: 1

Read full topic

Viewing all 70435 articles
Browse latest View live