Quantcast
Channel: Ionic Forum - Latest posts
Viewing all 228527 articles
Browse latest View live

Ionic 5 - How can i disable "back swipe" in IOS?

$
0
0

Hi,

I need to disable ios swipe on specific pages, but I can’t find a way to do it.

I also tried some solutions that I found in other threads, but none is compatible with Ionic 5. For example, in ionic 2 you can use:

<ion-view can-swipe-back="false">

I need the equivalent from ionic 5.

I could only disable swipe on ALL pages by adding the following to the app.module:

IonicModule.forRoot({
            swipeBackEnabled: false // A better spot to set swipe enabled also…
        }),

But i need disable only one…

stack:
Ionic: v5.16.0
Angular: v8.2.8

Thanks!


Use ionic components on standard Angular project

$
0
0

I got the same problem as you had and I find the way to solving it and helping everybody else who have the same issue…
You need to import IonicModule and CommonModule in components.module.ts to solve the problem.

@NgModule({
 imports: [
  CommonModule,
  IonicModule
 ],
 ...
})

then just need create a module in you`re project and then copy and past it....

Can't override default class css ionic v4

There was an error with the request: Cleartext HTTP traffic to localhost not permitted

$
0
0

I am working on ionic 4 using capacitor. I tried to call an api from localhost but am getting this error

There was an error with the request: Cleartext HTTP traffic to localhost not permitted !!

Runtime Error - Cannot Find Module "."

How to build this interface with ionic is it possible? or do I need react js or native android?

Apple no longer accepts apps without Sign in with Apple

$
0
0

Hi, i am stock with this implementation. Could you please share some example of your code?
I am following the instructions of the plugin, but it does nothing. I will appreciate it alot.

Trying to migrate project from older mac to newer mac

$
0
0

I can’t see why it wouldn’t be. Ionic projects out of the box are designed to be checked into git.

As you have discovered, you got a bunch of junk you don’t want. Look at the .gitignore file to see what you need to clean out, but again I think it would be easier to just start over and use version control.


Help in sending Get Request in Ionic

routerLink not updating url value when changed

$
0
0

While you wait for answers that will probably be more to your liking, I’m going to argue for a redesign. I would get all this segment mogrification out of pages and up into a service that provides appPages, so that it’s centralized.

Issue with ion-header

$
0
0

I am using the latest ionic 5 cli and I am using the popover controller to display a popup, however the ion-header is not fixed within the popup it simply scrolls with the other content, is this by design?

<ion-header *ngIf="hasSearchbar">
    <ion-toolbar>
        <ion-buttons slot="start">
            <ion-icon name="search"></ion-icon>
        </ion-buttons>
        <ion-input></ion-input>
    </ion-toolbar>
</ion-header>
<ion-content fullscreen="true">
    <ion-list>
        <ion-item
            *ngFor="let option of configuration.options"
            button="true"
            (click)="selectOption(option)"
        >
            <ion-label>{{ option[nameForText] }}</ion-label>
            <ion-icon
                *ngIf="isSelected(option[nameForValue])"
                slot="end"
                name="checkmark"
            ></ion-icon>
        </ion-item>
    </ion-list>
</ion-content>

Import { resolve } from 'path' not working - Ionic V4

$
0
0

This is a good idea.

This, however, isn’t, so…

Don’t. Reverse course. Take all that out.

This is probably also not a great idea, but I can’t say for certain because we aren’t shown what this.nativeStorage is. If it’s this ionic-native thingy, then I would move all interaction with it out of pages and into a service. This will isolate it and allow for more flexibility in the future. In any event, the only thing you should be doing with Promises in this context is chaining then clauses off of them.

Which leads me back to the beginning. Can you instead post the “before” version of this code, containing the “nesting promises in promises” you’re concerned about? I think it’s going to be easier to fix that than what we have here.

Cannot read property 'length' of undefined -v

$
0
0

This may seem like a PITA, and feel free to ignore me, but one thing I would try is to see if the problem persists if you limit yourself to only alphanumeric characters in all components of all paths that node ever sees. I’m specifically concerned about that ‘&’.

plugins.intentShim.registerBroadcastReceiver

$
0
0

Hi,
I have an array :
public tracks =;
and
constructor(
private plt: Platform, private changeDetectorRef: ChangeDetectorRef
) {
this.username = window.atob(localStorage.getItem(‘Token’)).split(’:’)[0];
(window).plugins.intentShim.registerBroadcastReceiver({
filterActions: [
‘com.symbol.datawedge.deluxescanner.ACTION’,
‘com.symbol.datawedge.api.RESULT_ACTION’
],
filterCategories: [
‘android.intent.category.DEFAULT’
]
},
function(intent) {
//alert('Received Intent: ’ + JSON.stringify(intent.extras));
if (intent.extras[“com.symbol.datawedge.data_string”] != null) {
// alert('Scan: ’ + intent.extras[‘com.symbol.datawedge.data_string’]);
const t: string = intent.extras[‘com.symbol.datawedge.data_string’].toString();
alert(t);
this.tracks.unshift(t);
alert(this.tracks[0]);

      }
  }

);
}
alert(t) is showing the correct value but ‘t’ is not inserted in the array by : this.tracks.unshift(t);
Any reason ?
Thanks

How can I remove extra height at the bottom of text in android: - IONIC4*

$
0
0

Hi All,

I have encountered with a weird issue with ionic4 framework. Ionic4 is adding extra height at the bottom of the text in Android, where as on iOS the above and below height is same.

Below is sample code
RECENT ACTIVITY

Not only on ion-label but where ever I have text in the app, the extra space/height is being added at the bottom on Android app.

[the above image is when am debugging in chrome]

If you observe very closely the text is not center aligned ON ANDROID, which works fine in iOS*
No padding or margin is applied. only text-align center is applied,

To make the text appear on android I have to add 2px extra padding on top of every text element.

I hate to add padding on each and every element like this, Really appreciate if you can suggest me to make it work on global level

Note: this is nothing to do with CSS (like flex,justify, line height etc), the extra height is added at bottom on ANDROID. on the text it self.

To understand the issue, inspect any ionic app on android and hover on text (don’t apply any css property or padding and closely check above and below height of the text)

Related observations and solutions are much appreciated.

Thank you


plugins.intentShim.registerBroadcastReceiver

How to change text shown on ion-select when value is changed?

$
0
0

Hmm. Is there a chance your problem actually lies elsewhere? The following acts like it sounds like you are expecting for me (unless I’m misunderstanding you, which is entirely possible):

export class HomePage {
  fruits = [{id: "a", name: "apple"}, {id: "b", name: "banana"}, {id: "c", name: "cherry"}];
  fg = new FormGroup({fruit: new FormControl()});

  pickBanana(): void {
    this.fg.patchValue({fruit: "b"});
  }
}
<ion-content>
    <form [formGroup]="fg">
        <ion-item>
            <ion-select formControlName="fruit">
                <ion-select-option *ngFor="let fruit of fruits" [value]="fruit.id">
                    {{fruit.name}}
                </ion-select-option>
            </ion-select>
        </ion-item>
    </form>
    <ion-button (click)="pickBanana()">pick banana</ion-button>
</ion-content>

There was an error with the request: Cleartext HTTP traffic to localhost not permitted

$
0
0

That message suggests two courses of action, both of which sound like great ideas to me:

  • put the backend somewhere other than localhost
  • interact with it via HTTPS

Ionic 4 detect when html 5 audio player starts playing

$
0
0

Hi,
I have a number of audio files loaded on page similar to how it is written below:

<ion-item *ngFor="let programme of radioProgrammes" class="radio-file">
              <audio controls preload>
                <source [src]="programme.radio_file" type="audio/mpeg">
                Your device does not support the audio element.
              </audio>
</ion-item>

The issue is I want to stop the user from playing more than 1 audio file at a time.

I have already written a function pause all other audio files if they are playing but but I cant figure out how to detect when the file starts playing.

I originally tried adding (click)=“pauseOtherPlayers()” to call the function eg:

 <audio (click)="pauseOtherPlayers()" controls preload>
                <source [src]="programme.radio_file" type="audio/mpeg">
                Your device does not support the audio element.
</audio>

but that didn’t work.

Thanks in advanced to anyone who can help me with this issue.

Updating list upon ionic storage set() completion

$
0
0

Sorry in advance for the the lengthy post.

I am still pretty new to the PWA world and am having trouble getting values added to Storage to show up upon return to my customer list

My Service:

import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
import { Customer } from './models/customer';
import { StorageConstants } from './storageConstants';
import { Observable } from 'rxjs/Observable';
import { from } from 'rxjs';
import { map, tap } from 'rxjs/operators';

@Injectable({
  providedIn: 'root'
})
export class CustomersService {

  constructor(private storage: Storage) { }

  getCustomers() : Observable<Customer[]>{
    return from(this.storage.get(StorageConstants.customers)).pipe(
      map((customers) => {
        return customers ? JSON.parse(customers).map(
          (customer: Customer) => new Customer(customer)) : []
      })
    )
  }

  addCustomer(customer: Customer) {
    let customers_update: Customer[];
    return this.getCustomers().pipe(
      tap(
        (customers : Customer[]) => {
          customers_update = customers;
          customers_update.push(customer);
          this.storage.set(
            StorageConstants.customers, JSON.stringify(customers_update));
        }
      )
    );
  }
}

My Form component

import { Component, ViewChild, OnInit } from '@angular/core';
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { CustomersService } from '../customers.service';
import { Customer } from '../models/customer';
import { Router } from '@angular/router';

@Component({
  selector: 'app-customer-form',
  templateUrl: './customer-form.page.html',
  styleUrls: ['./customer-form.page.scss'],
})
export class CustomerFormPage implements OnInit{
  @ViewChild('customerForm', {static: false}) formValues;

  private  addCustomer: FormGroup;
  constructor(
    private formBuilder: FormBuilder,
    private customersService: CustomersService,
    private router: Router
  ) {
    
    this.addCustomer = this.formBuilder.group(
      {
        name: ['', Validators.required],
        phone: ['', Validators.required],
        email: ['']
      }
    );
   }

   ngOnInit() {}

  onSubmit() {
      const newCustomer: Customer = new Customer(
        {
          name: this.addCustomer.value.name,
          phone: this.addCustomer.value.phone,
          email: this.addCustomer.value.email
        }
      );

      this.customersService.addCustomer(newCustomer).subscribe(
        {
          complete: () => this.router.navigate(['tabs', 'customers'])
        }
      );
  }

}

My list component

import { Component, OnInit } from '@angular/core';
import { CustomersService } from '../customers.service';
import { Customer } from '../models/customer';
import { NavController } from '@ionic/angular';
import { Observable } from 'rxjs';

@Component({
  selector: 'customers',
  templateUrl: 'customers.page.html',
  styleUrls: ['customers.page.scss']
})
export class CustomersPage implements OnInit{

  private customers: Observable<Customer[]>;

  constructor(private customersService: CustomersService) {}

  ngOnInit(): any {
    this.customers = this.customersService.getCustomers();
  }
}

List html

<ion-content>
  <div *ngFor="let customer of customers | async">
    <h2>{{customer.name}} {{customer.phone}}</h2>
  </div>
</ion-content>

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
  <ion-fab-button [routerLink]="['add-customer']">
    <ion-icon name="add"></ion-icon>
  </ion-fab-button>
</ion-fab>

Adding a customer via the addCustomer method in the service adds to Storage, but the list in the component is only updated upon refresh. I looked around and tried a lot of solutions, but I think I am missing a fundamental understanding about how these pieces are working together.

Any help is greatly appreciated.

Viewing all 228527 articles
Browse latest View live


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