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

Ion-list alignment

$
0
0

I tried to adjust the CSS on the ion-item component, ion-list component, and the app component.

ion-content {
align-content: flex-start;
text-align: left;

–padding-bottom: 0px;
–padding-end: 0px;
–padding-start: 0px;
–padding-top: 0px;
}

ion-page {

align-content: flex-start;
text-align: left;

–padding-bottom: 0px;
–padding-end: 0px;
–padding-start: 0px;
–padding-top: 0px;
}

ion-list {

align-content: flex-start;
text-align: left;

–padding-bottom: 0px;
–padding-end: 0px;
–padding-start: 0px;
–padding-top: 0px;
}

2 posts - 2 participants

Read full topic


How to Dynamically pass Icon Names

$
0
0

I have a Template which has several child components one of the components take a array as prop.

In that array, I have a field named icon which contains the name of the icon that is to be set…

For example, I have a list and a component that take an array field as shown below

const list = [];

list =[
{
title:"item1",
icon:"boat-outline"
}
{
title:"item1",
icon:"airplane-outline"
}
]

My Problem is how can i set this icon inside my child component.

Attempt 1
i added the

<script src="https://unpkg.com/ionicons@5.4.0/dist/ionicons.js"></script>

to the index.html and used name={{listItem.icon}} in my template… and that did not work, in browser i get the following error

Failed to load module script: The server responded with a non-JavaScript MIME type of “text/html”. Strict MIME type checking is enforced for module scripts per HTML spec.

Attempt 2
Inside my child component i did import "ionicons/icons", and in data i returned a listIcon a second array full of Icon names, and binded them using :icon
this still did not work…

NOTE: i am using Options API and Not Composition

Any Suggestion or pointers

10 posts - 3 participants

Read full topic

Possible to set fill="outline" (or other tags) for ion-button etc CENTRALLY?

$
0
0

I know about css of course in variables.scss and other places - just can’t find anything on centrally changing all buttons of my app to default fill=“outline” without search+replace all the code… Is it possible?

Using ionic 5+capacitor 2 going on 3 +angular and that rocks very much

4 posts - 2 participants

Read full topic

How to use response outside the function?

$
0
0

In response, there is only one value. So how can I use that response outside of function?
Whenever I tried to use outside function it is showing in console undefined.

this.adminService.getlastfid().subscribe( response =>{
this.lastid = response ;
//console.log(data)
});

let l_id = this.lastid;
console.log(l_id);

1 post - 1 participant

Read full topic

Clear Routing Stack does not work

$
0
0

Hello,

Actually i’m working with Ionic-v4 (Angular), i tried to use all API’s like: .setRoot , .navigateRoot, .pop, .push, using options like replaceUrl:true, skipLocationChange: true, navigateForward, navigateBackward etc… to clear stack pages, but none of these suggestions do the job.

I want to clear all ionic stack pages whenever i logout from the application, this is my logout code i used:

In my service file, here is the logout process:

    /**
     * Logout connected user
     * @param {function} onLoggedOut callback maybe called after logged out
     * @param forcedLogout
     */
    logout(onLoggedOut = null, forcedLogout = false) {
        if (forcedLogout) {
            this.frontLogout();
        } else {
            this.http.post(`${this.config.apiUrl}to-logout`, {})
                .subscribe(
                    data => {
                        this.frontLogout();
                        if (onLoggedOut) {
                            onLoggedOut();
                        }
                    }
                );
        }
    }

    /**
     * Front logout
     * @private
     */
    private frontLogout() {
        localStorage.removeItem('currentUser');
    }

in my menu page here is the logout process using the previous service:

    /**
     * logout service
     */
    private disconnect(withNavigation = true) {
        this.authService.logout(async () => {
            if (withNavigation){
                await this.navCtrl.navigateRoot(['/'], ROUTER_CONFIG_BACK);
            }
        });
    }

Important: the ‘/’ route is pointing on a lazyloading module:
app-routing.module.ts

   {
        path: '',
        canActivateChild: [AuthenticatedUserGuard],
        loadChildren: () => import('./lancement/lancement.module').then(m => m.LancementPageModule)
    },

lancement.module.ts

 {
    path: '',
    component: LancementPage
  }

Thank you in advance.

1 post - 1 participant

Read full topic

I can't build ionic react app on IOS simulator

$
0
0

I’m trying to build an Ionic React project. I’m successfully compiling the project on the IOS simulator but It crashes when It opens. Error showing is

ERROR: Unable to load public/index.html
:zap: This file is the root of your web app and must exist before
:zap: Capacitor can run. Ensure you’ve run capacitor copy at least
:zap: or, if embedding, that this directory exists as a resource directory.

Please help me to get it fixed

1 post - 1 participant

Read full topic

How to properly have nested views to display?

$
0
0

Hey there! So currently were working on a project which has many nested routes which must display. The reason being is were having two separate components displaying at the same which will switch out when clicked on. My question is how do we properly get a nested view to dynamically display?

To give you an idea of our hierarchy we have:
VIEW
|
HOME
|
CARD - Here is where we wish to display the various cards, I’ve gotten everything to display up to this point.

Here’s our current code for the files which we are trying to display:

HTML-----------------

    <ion-router-outlet name="view1"></ion-router-outlet>
    <ion-router-outlet name="view2"></ion-router-outlet>
</ion-grid>

CARD.PAGE.ROUTING.MODULE--------------

{
path: ‘card-page’,
component: CardPage,
children: [
{
path: ‘view1’,
outlet: ‘view1’,
loadChildren: () => import(’…/view1/view1.module’).then(m => m.View1PageModule)
},
{
path: ‘view2’,
outlet: ‘view2’,
loadChildren: () => import(’…/view2/view2.module’).then(m => m.View2PageModule)
}

I appreciate any help or hints, please let me know if you wish for me to expand on anything, Thank you for your time!

1 post - 1 participant

Read full topic

How to create multi-column layout on desktop, paged on mobile

$
0
0

I’m just about to start my first ionic app with vue. Never used ionic before and I’m pretty new to vue but otherwise an experienced dev.

Anyway, the app I’m building needs to have multiple columns showing on desktop as user selects options but on mobile it should show these as one page at a time. I’m wondering if it’s possible to achieve this with ionic and how I might best go about that. Here’s how it should look on desktop:

So first an option would be chosen from the first column, which would then display/enable the middle column and finally the right column once a middle column choice had been made.

On mobile it should show the left-most column as a page first, then when a choice has been made the middle column would show and finally the right most column. So this would be the first screen to be shown:

What would be the best approach here?

TIA!

1 post - 1 participant

Read full topic


Expand ion-row to fill remaining height of grid?

$
0
0

Is there any Ionic CSS utility to stretch a row in a grid so that it fills the remaining empty space(height)? Let’s say I have a grid with a fixed height. In the grid there’s 3 rows. The first two take the height of the items in their columns. The third row should expand in order to fill the remaining height of the grid.
Maybe the pic below makes it clearer:
iongrid

1 post - 1 participant

Read full topic

Ionic use npm and javascript library

$
0
0

Hi everyone I need help.

Can I use javascript and npm library in ionic angular ??

1 post - 1 participant

Read full topic

Base64 to Gallery plugin not work in Ionic 4 and 5

$
0
0

Plugin is :: Base64 To Gallery - Ionic Documentation

When I saved a image into gallery then show this error “Error while saving image”

Code ::
downloadQR(){
const canvas = document.querySelector(‘canvas’) as HTMLCanvasElement;
const imageData = canvas.toDataURL(‘image/jpeg’).toString()
console.log(imageData)
let data = imageData.split(’,’)[1];
console.log(data)
this.base64.base64ToGallery(data, {
prefix:’_img’,mediaScanner : true}).then(async res=>{
console.log(res)
let toast = await this.toastCtrl.create({
header : ‘QR code save’
})
toast.present()
}, err => console.log(“err”,err)
)
}

What is problem of my code? any other solution ??

1 post - 1 participant

Read full topic

Ionic 5 app with Android 8 platform cannot access internet on devices with Android OS above 8

$
0
0

Hello
my ionic 5 application can access my API via internet on phones with an android version below 9. but on phones with android versions above 8, it can’t find the API.
I added the platform to my project with the command

cordova platform add android@8

1 post - 1 participant

Read full topic

[XPC] Handle connection with error: Connection interrupted

$
0
0

I have used video tag to display video which has source of online URL. but video duration is around 2 hours.
when video is playing and if user tap on home button(app goes to background mode). and after that if user opens app then video will continue till 20-25 seconds. and then app is crashing.
It is giving below “error [XPC] Handle connection with error: Connection interrupted”. This is showing in xcode console.
It is only reproducible in ios 14.4 devices.
Can anyone help me?

1 post - 1 participant

Read full topic

Scroll Freezes When Changing Windows

$
0
0

Encountering a bug when trying to switch from one ionic slide to the next: Loom | Free Screen & Video Recording Software

Anybody think they know what the problem could be?

import { Component, OnInit, ViewChild, ChangeDetectorRef } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Work } from 'src/app/interfaces/work';
import { SelectedWorksService } from 'src/app/services/selected-works.service';
import { DataApiService } from 'src/app/services/data-api.service';
import { IonSlides, AlertController } from '@ionic/angular';
import { from } from 'rxjs';
import { Artist } from 'src/app/interfaces/artist';
import { User } from 'src/app/interfaces/user';
import { Tag } from 'src/app/interfaces/tag';

interface OrientationSlide {
  name: string,
  hasLoaded: boolean,
  works: Array<Work>,
}

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

  @ViewChild("slides") slides: IonSlides;

  slideOpts = {
    initialSlide: 0,
    speed: 400,
    autoHeight: true,
    resizeObserver: true,
    updateOnWindowResize: true,
  };
  activeSlide = 0;
  orientations: Array<OrientationSlide> = [
    {
      name: "portrait",
      hasLoaded: false,
      works: [],
    },
    {
      name: "landscape",
      hasLoaded: false,
      works: [],
    },
    {
      name: "square",
      hasLoaded: false,
      works: [],
    },
    {
      name: "panoramic",
      hasLoaded: false,
      works: [],
    },
  ];

  user: User = null;
  pageTitle: string = null;

  // Possible filter data
  artist: Artist = null;
  genre: Tag = null;

  constructor(
    private router: Router,
    private route: ActivatedRoute,
    private selectedWorksService: SelectedWorksService,
    private dataApi: DataApiService,
    private changeDetector: ChangeDetectorRef,
    private alertController: AlertController,
  ) { }

  ngOnInit() {
    let portraitOrientation = this.orientations.find(o => o.name === 'portrait');
    portraitOrientation.works = this.route.snapshot.data['works'];
    portraitOrientation.hasLoaded = true;

    this.user = this.route.snapshot.data['user'];

    // Filters
    this.artist = this.route.snapshot.data['artist'];
    this.genre = this.route.snapshot.data['genre'];

    this.pageTitle = (this.artist && `${this.artist.firstName} ${this.artist.lastName}`)
      || (this.genre && this.genre.name) || null;
  }

  async onWorkClick(work: Work) {
    if (!this.user.isPremier()) {
      this.router.navigateByUrl(`/tabs/work/${work.workId}`);
      return;
    }

    if (work.hasPermission) {
      this.selectedWorksService.toggle(work.workId.toString());
    }
    else {
      const alert = await this.alertController.create({
        header: 'upgrade subscription',
        message: 'You are not currently subscribed to view this work.',
        buttons: ['ok']
      });

      await alert.present();
    }
  }

  onSelectedWorksClick() {
    this.router.navigate(['/tabs/selected-works/choose-display']);
    // const workIds = this.selectedWorksService.getSelected();
    // if (workIds.length === 1) {
    //   const workId = workIds[0];
    //   this.router.navigate([`/tabs/work/${workId}/choose-display`]);
    // } else {
    //   this.router.navigate(['/tabs/selected-works/choose-display']);
    // }
  }

  isSelected(workId: number) {
    return this.selectedWorksService.isSelected(workId.toString());
  }

  getNumSelected() {
    return this.selectedWorksService.getSelected().length;
  }

  clearSelected() {
    this.selectedWorksService.clear();
  }

  goToOrientation(orientation: string) {
    this.slides.slideTo(this.orientations.findIndex(o => o.name === orientation));
  }

  goToArtistSlide() {
    this.slides.slideTo(this.orientations.length);
  }

  onSlideChange() {
    from(this.slides.getActiveIndex()).subscribe(i => {
      let orientation = this.orientations[i];

      if (i !== 0 && orientation && orientation.works.length === 0) {
        let filter = this.route.snapshot.paramMap.get('filter');
        let filterValue = this.route.snapshot.paramMap.get('filterValue');
        let filters = [{
          name: 'orientation',
          value: orientation.name
        }];

        if (filter) {
          filters.push({ name: filter, value: filterValue });
        }

        this.dataApi.getFilteredWorks(filters).subscribe(works => {
          orientation.hasLoaded = true;
          if (works) {
            orientation.works = works;
            this.changeDetector.detectChanges();
          }
        });
      }

      this.activeSlide = i;
    });

  }
}

Here is the code above for the window shown in the loom where it freezes on tab change to a new window. Is there an easy fix for this?

1 post - 1 participant

Read full topic

How to show parent page when user slide from left from a detail page?

$
0
0

Usually in a native app when you are on a detail page and you slide from the left side you can see a preview of the previous page from which you were coming.

I’ve just created an app from scratch from the list starter template but when I go into the list detail and I try to emulate the slide gesture the transition not used.

What am I missing? It’s not implemented by default? How can I enable it?

2 posts - 2 participants

Read full topic


No navigation animation when I use router.push?

$
0
0

Is it possible to disable the animation transition between two pages ?

I would like to keep the animation for some nested routes but disable it for other links.

For now I navigate between pages programmatically like this, but I don’t think I can disable the animation directly in $router.push

this.$router.push('/game/' + this.$route.params.gameId + '/' + pageId);

And if I disable the animation on the router-outlet it will disable animation for all links.

5 posts - 2 participants

Read full topic

IonViewDidEnter not working

$
0
0

I am trying to use ionic lifecycle hook ionViewDidEnter() . but it is giving error

   59:5  error  'ionViewDidEnter' is not defined  no-undef

that’s how I am trying

 setup() {
    ionViewDidEnter(() => {
      console.log('Home page did enter');
    });

      const router = useRouter();
      return { router };
    },

1 post - 1 participant

Read full topic

How to hide the Scroll Bar in the ios Simulator? (Vue.js)

$
0
0

Hello,

I have a problem with hiding the Scroll Bar on scrolling. Can someone help me how to solve that? Thanks.

This is my code.

<template>
  <ion-page>
    <ion-content :scroll-events="true" :scroll-y="true" :fullscreen="false">
      <div v-for="item in items" :key="item.id">
        {{item.id}}
      </div>
    </ion-content>
  </ion-page>
</template>

Ionic version:

Ionic:

   Ionic CLI       : 6.13.1 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/vue 5.6.3

Capacitor:

   Capacitor CLI   : 2.4.6
   @capacitor/core : 2.4.6

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v14.16.0 (/usr/local/bin/node)
   npm    : 7.6.0
   OS     : macOS Big Sur

And here is a Screenshot.

1 post - 1 participant

Read full topic

Sound lag on IOS

$
0
0

HI.
I can run my awesome ionic app on android with no problem.
On IOS, it work perfectly if i disable sound. If sound is enable, each sound playing make the app lag…

I use the HTMLAudioElement like this:

audio = new Audio('/assets/sounds/mySound.mp3');
audio.play();

An error message say on xcode:
Failed to acquire RBS MediaPlayback assertion ‘Webkit Media Playback’ for process whit PID 1416

Do you have an idea of what happen (i suppose this is a question of thread) ?

Thanks

1 post - 1 participant

Read full topic

Application navigation stuck between pages

$
0
0

I have released a new application with ionic and it works well in ios and android but when i tested in oneplus , sometimes pages stuck between two pages and ion backbutton was also not working. One plus device having swipe back to navigate and i also enabled swipe back in the application too is it the issue for that? I don’t know why it happened like this. Anyone please help me

1 post - 1 participant

Read full topic

Viewing all 49305 articles
Browse latest View live


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