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

Lazy loading phone contacts

$
0
0

@codiqa100078139 wrote:

Hi there

I need to add an option of importing phone contacts to the app I am building.
So I work with the cordova-plugin-contacts to get all the contacts in the phone.
I tried to use the alert component with the check options but with a list of 1000+ check options it gets stuck/freeze :frowning:

So i am trying to work with Modal component.
I send the contact list result to a modal page where the user can check the contacts he wants to import.
And click ‘Import’ button.

What appends is that all the list is stuck/freeze.

I have more then 3000 contacts…
Y dose it get stuck???
How can maybe lazy load the 3000+ contact list list?
I am stuck with this for days :frowning:

Here is my code:

Import button:

openContactListClient(){
    if(this.platform.is('cordova')){
      this.loadingElem = this.loadingCtrl.create({
        spinner: 'ios',
        content: 'Getting contact list please wait...'
      });
      this.loadingElem.present();

      var opts = {
        fields: ['displayName', 'name' , 'emails', 'addresses'],
        multiple: true,
        hasPhoneNumber:true
      };
      this.contacts.find(['displayName', 'name' , 'emails', 'addresses'],opts).then((contacts) => {
        contacts.filter((item) => {
          var id = item.id;
          if(item.addresses!=null){
            var address = item.addresses[0].formatted;
          }
          if(typeof item.name.givenName!=='undefined'){
            var first_name = item.name.givenName;
          }
          if(typeof item.name.familyName!=='undefined'){
            var last_name = item.name.familyName;
          }
          if(item.emails!=null){
            var email = item.emails[0].value;
          }
          if(item.phoneNumbers!=null){
            var phone = item.phoneNumbers[0].value;
          }
          let clientData = {
            id:id,
            address: address,
            first_name: first_name,
            last_name: last_name,
            email: email,
            phone: phone
          };
          this.phoneContactList.push(clientData);

        })
        this.loadingElem.dismiss();

        let modal = this.modalCtrl.create('ContactListPage',{
          business_id: this.business_id,
          contact_list: this.phoneContactList
        });
        modal.present();

      }, (error) => {
        console.log(error);
      })
    }else{
      //error...
    }

  }

Here is the ContactListPage modal page .ts:

export class ContactListPage {

  business_id: number;
  contact_list = []

  constructor(public navCtrl: NavController, public navParams: NavParams, public viewCtrl: ViewController) {
    this.business_id = this.navParams.get('business_id');
    this.contact_list = this.navParams.get('contact_list');
  }

  ionViewDidLoad() {
  }

  dismiss(){
    this.viewCtrl.dismiss();
  }
}

Here is the ContactListPage .html

  <ion-list>
    <ion-item *ngFor="let contact of contact_list">
      <ion-avatar item-start>
        <!-- some avatar -->
      </ion-avatar>
      <h2>{{contact.last_name}} {{contact.first_name}}</h2>
      <div *ngIf="contact.phone!=''">{{contact.phone}}</div>
      <div *ngIf="contact.email!=''">{{contact.email}}</div>
      <div *ngIf="contact.address!=''">{{contact.address}}</div>
    </ion-item>
  </ion-list>

Posts: 1

Participants: 1

Read full topic


Element positioning and dragging in Ionic

$
0
0

@leegee wrote:

What is the current best practice for dynamically added elements with dynamic positioning?

What would be the best event to which to subscribe?

What is the best way to dynamically set the position?

Sorry the questions are so generic: only just started looking at the framework, and most of the info on this subject seems to relate to various v1 betas and release-candidates.

Posts: 1

Participants: 1

Read full topic

Random Typescript Errors at Reload

$
0
0

@IndyJones72 wrote:

I use WebStorm for development and lately I’ve been really puzzled by the environment as a whole and seeing if anyone else has experienced this.

So I’ll make changes, add classes/code…the usual…and live reload will compile the ts and display the app in the browser via my terminal which obviously is running the ionic serve.

Now sometimes I’ll make a change or just refresh the page and viol’a I have a typescript error which wasn’t there before, but exists on a page where code has not been modified.

I thought live reload / web pack recompiles everything but maybe I’m missing a parameter or setting somewhere? Any help appreciated.

Posts: 3

Participants: 3

Read full topic

Cordova-plugin-file-transfer .. application is unbearably slow

$
0
0

@anton_klochko wrote:

Hi all ! Could anyone suggest please … In my Ionic 3 app when I am run downloding zip file … 50 - 100 megabyte … my app can not do anything. I can not go back, can not open new page … application is unbearably slow … only after downloading process finished … running back button event … It is not normal, yes ?

Posts: 1

Participants: 1

Read full topic

Help with positioning of fields in list item

$
0
0

@bassfan wrote:

I have a list with a bunch of input fields. One of them is a weight, in pounds (lbs) and ounces (oz). These inputs should be in the same row as represented by the "11"s in the image below. I have it close, but I can’t seem to figure out how to get them to match the other labels/inputs above and below in the list. The most obvious thing is I can’t seem to wrap this in <ion-item>. Anytime I do, nothing is shown at all in that list item. However if I remove it, it looks like the below. I only need max two digits for the “oz” input and max three digits for the “lbs” input.

help1

Here is what I want it to look like, plus the text sizes should match the other list items. I imagine if I can just get the ion-item tags in there, that will solve that though.

help2

Can anyone offer a suggestion?

Here is the relevant snippet from my html.

          <ion-grid no-padding>
            <ion-row justify-content-center align-items-center style="height: 100%">
              <ion-col col-6>
                <ion-label>Weight</ion-label>
              </ion-col>
              <ion-col>
                <ion-input type="number" [(ngModel)]="lb" text-right></ion-input>
              </ion-col>
              <ion-col>
                <ion-label>lb</ion-label>
              </ion-col>
              <ion-col>
                <ion-input type="number" [(ngModel)]="oz" text-right></ion-input>
              </ion-col>
              <ion-col>
                <ion-label>oz</ion-label>
              </ion-col>
            </ion-row>
          </ion-grid>

Posts: 2

Participants: 1

Read full topic

Inside button navpush not working

$
0
0

@Erdenemunkh wrote:

<ion-item *ngFor="let hh of householdList" detail-push navPush="EditHouseholdPage" [navParams]="{ownerId: hh.id}">
			<h2>{{ hh.q7 }}</h2>
			<h3>{{ hh.q8 }}</h3>
			<button ion-button outline item-end icon-left navPush="AddChildPage">
				<ion-icon name="add"></ion-icon> Child
			</button>
		</ion-item>

I’m clicked inside button after navigate AddChildPage. It is correct, but same time navigate EditHouseholdPage.
Why same time navigate EditHouseholdPage, How to solve this problem?

Posts: 1

Participants: 1

Read full topic

Landscape/virtualScroll

$
0
0

@utbc wrote:

Hi Ionic Experts!

Here is my situation, I have an ionic app which has to load large quantities of data. (calendar info, and there may be 300-600 displayed on a given calendar entry)

IOS: without virtualScroll it is unusable so we must use virtualScroll on this screen.

Android: works with MOST devices without virtualScroll, but occasionally a specific device cannot scroll at all and virtualScroll fixes this.

So you say you will just tell me, “then just use virtualScroll on all your screens” right?

  • wrong, apparently virtualScroll DOES NOT work flawlessly when the phone is tipped into “landscape” mope (which is a pain because phones should be able to go into landscape mode as that is what they were designed to do)

Solution 2: use virtualScroll on select screens and block landscape mode on those screens.

now 99% of my issues are resolved with an occasional loading issue that is corrected if you reload that page

so im stuck with virtualScroll because we must support IOS but virtualScroll doesnt play well with phones in landscape mode and doesnt load data properly 100% of the time. its extremely flaky. has anyone had any experience with an issue like this?

thanks!!

CODE SNIPPET USING VIRTUALSCROLL

<ion-list class="schedule-list" [virtualScroll]="items">
	<ion-item class="schedule-item" *virtualItem="let item" text-wrap>
		<ion-row>
			<ion-col class="schedule-data">
				<div class="data-item">
					<div class="item-content">

…lots more in this table…but this is how the code renders the screen

Posts: 1

Participants: 1

Read full topic

Best way to create space around ionic page

$
0
0

@ghostrunners wrote:

The DOM for my ionic page looks like this -

<ion-header></ion-header>
<ion-content></ion-content>
<ion-footer></ion-footer>

I tried wrapping a div around it to create a margin of 20x, the applied to to body, then to page-my-client element, and every time it only applies the top and left margins.

What I am trying to is establish whitespace around my ionic page symmetrically, and before I went deeper into the sass/css, is there was a way to do this already?

Posts: 1

Participants: 1

Read full topic


Ngrx store & effects using Storage?

$
0
0

@ozexpert wrote:

Having a hard time learning Ngrx effects. I’m using ngrx/store to manage my state. However, I’d like to have Ngrx effects to handle saving to Ionic Storage when state is changed. However, I’m not sure how I can do that.

I have the following code, but dispatching with type UPDATE_SETTINGS won’t get the changed state, so I can’t really change it in the storage. Does anyone have a similar example of using ngrx/effects? anything similar to this would help. Thanks!

import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { Actions, Effect } from "@ngrx/effects";
import {
  GET_SETTINGS,
  UPDATE_SETTINGS,
  UPDATE_SETTINGS_SUCCESS,
  Action,
  AppState
} from '../_reducers/settings.reducer';
import { StorageProvider } from '../providers/storage/storage';
import { Observable } from "rxjs";

const storageKey = 'settings';

@Injectable()
export class SettingsEffects {
  constructor(
    private storage: StorageProvider,
    private actions$: Actions,
    private store$: Store<AppState>
  ) {}

  @Effect() get$ = this.actions$
    .ofType(GET_SETTINGS)
    .mergeMap((action: any) => Observable.fromPromise(this.storage.get(storageKey))
        .map(data => ({ type: UPDATE_SETTINGS, payload: data }))
        .catch(() => Observable.of()))
    .catch(() => Observable.of());

  @Effect() update$ = this.actions$
    .ofType(UPDATE_SETTINGS)
    .switchMap(() => {
      return Observable.of({ type: "UPDATE_SETTINGS_SUCCESS" })
    });

  @Effect() updateSuccess$ = this.actions$
    .ofType(UPDATE_SETTINGS_SUCCESS)
    .do(() => {
      console.log('update settings success called');
    })
    .withLatestFrom(this.store$)
    .switchMap(([ payload, store ] : any) => {
      return Observable.fromPromise(this.storage.set(storageKey, store.settings))
        .catch(() => Observable.of())
    })
    .catch(() => Observable.of());
}

Posts: 1

Participants: 1

Read full topic

Parameter of type 'DocumentDirection' Cannot read property ‘dir’ of undefined

$
0
0

@rootthenile wrote:

Hi I just make a multi language app with RTL for the menu

here’s my code in my Settings Page ts where the change language bottom there

export class SettingsPage {
  languageSelected : any = 'en';
  languages : Array<LanguageModel>;
  dir: string;

  constructor (
    public navCtrl: NavController,
    public translate: TranslateService,
    public languageService: LanguageService,
    public platform:Platform

  )


  {
    this.languages = this.languageService.getLanguages();
    this.setLanguage();
  }


  changeLanguage(languageId) {
    if (languageId === 'ar') {
      this.platform.setDir('rtl', true);
      this.translate.setDefaultLang(languageId);

    } else {
      this.platform.setDir('ltr', true);
      this.translate.setDefaultLang(languageId);
    }
  }


  setLanguage(){
    this.dir = this.dir == 'ltr' ? 'rtl' : 'ltr';
    this.platform.setDir(this.dir,true);
    let defaultLanguage = this.translate.getDefaultLang();
    if(this.languageSelected){
      this.translate.setDefaultLang(this.languageSelected);
      this.translate.use(this.languageSelected);

    }else{
      this.languageSelected = defaultLanguage;
      this.translate.use(defaultLanguage);
    }
  }

}

and I get error Cannot read property ‘dir’ of undefined

Posts: 1

Participants: 1

Read full topic

Ionic app not showing view properly in iOS 9.3.4

$
0
0

@desmart92 wrote:

Hi all. I’m facing issue in my ionic app view in Page for iOS version. Please noticed that the android version work like charm.
I have 4 reports but it’s show 2
Here is my view problem in image…

Here my code page view

ion-list>
      <ion-item *ngFor="let rp of reports" text-wrap>
        <ion-row class="report" [ngClass]="rp.isDownloaded ? 'downloaded' : ''">
          <ion-col col-9 (click)="openOrDownloadFile(rp)">
            {{rp.Titre}}
            <span [hidden]="!checkDownloading(rp)">
                <br /><ion-spinner icon="dots"></ion-spinner>
            </span>
          </ion-col>
          <ion-col col-3 class="dateReport" text-right>
            <span class="small">{{rp.DatePub| date: 'dd/MM/yyyy'}}</span><br>
            <span class="small">{{rp.DatePub| date: 'H:mm'}} GMT</span>
            <div [hidden]="!checkDownloading(rp)" text-center>
                <ion-icon ios="ios-close-circle" md="md-close-circle" (click)="abordDownloadFile(rp)" class="i-2x"></ion-icon>
            </div>
          </ion-col>
        </ion-row>
      </ion-item>
    </ion-list>

In my page.ts here part of code

getAlerteReports(refresherManuel?){
    if(this.isOnline) {
      this.getEmptyReports = false;
      this.ServiceWebApp.getAlerteReports(this.UserConnected.IdClient)
      .subscribe(reports => {
        //this.reports = reports.json();

I get console.log(this.reports) in my component and all reports are getting with success

Don't forget that my view rendered properly in android version. Only iOS version has issue.

Here my environment

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.18.0
    ionic (Ionic CLI) : 3.18.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.2
    Cordova Platforms  : ios 4.4.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    ios-deploy : 1.9.2
    Node       : v8.9.1
    npm        : 5.5.1
    OS         : macOS Sierra
    Xcode      : Xcode 9.1 Build version 9B55

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

Thank for help

Posts: 1

Participants: 1

Read full topic

Publish a app to Google Play

$
0
0

@carloscruz85 wrote:

There are a tool in CLI to sing and align a release apk?

I need to upload my app to Google Play, I’m really confused.

Thanks for the answer!

Posts: 4

Participants: 2

Read full topic

HTTP with SOAP web service (xml)

Connection to the server was unsucceful while running my ionic app on android tablet

$
0
0

@kmx1 wrote:

Just builded my first apk for my ionic app and im getting this error while tryng to run with my tablet ( android versio 4.0) i already tried adding this line to config xml

 <preference name="loadUrlTimeoutValue" value="700000" />

I stop getting the error, but then it never loads… the apk runs fine on my celphone Xperia, any ideas why this happens only on the tablet?

ionic info

cli packages: (/usr/lib/node_modules)

@ionic/cli-utils  : 1.12.0
ionic (Ionic CLI) : 3.12.0

global packages:

cordova (Cordova CLI) : 7.0.1

local packages:

@ionic/app-scripts : 3.0.1
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.8.0

System:

Android SDK Tools : 26.1.1
Node              : v8.6.0
npm               : 5.4.2
OS

Posts: 1

Participants: 1

Read full topic

Subscribe to Navbar back button?

$
0
0

@theaccordance wrote:

Does anyone know if there’s a way to hook into the navbar’s back button for a specific view? I’d like to subscribe to the interaction and fire off an action in redux to update the application state.

I tried page events, but I was getting some unexpected behavior & it wasn’t clear how I could identify the back button action

Posts: 4

Participants: 3

Read full topic


Timing out on unsubscribed GPS call - background geolocation & geolocation - ionic

$
0
0

@ajammon wrote:

I’m able to retrieve GPS - lat and long. The issue is, the device is trying to get a GPS reading every second from ionic native geolocation. I’m using both geolocation and background geolocation. The issue is my watch position on the geolocation is running until I unsubscribe (which makes sense). Maybe this is trivial and I’m over thinking but I should be able to unsubscribe right after I subscribe to watch position and retrieve that data correct? Wrong. I’m not able to even read a console.log message inside of the subscription if that’s the case. I’m unsubscribing from watch in the stop tracking but I’m still getting a console message of the GPS data every second until stop tracking is hit, which is every 30 seconds. thanks

map.ts

    startTracking() {

        console.log('started tracking')
        const config: BackgroundGeolocationConfig = {
          desiredAccuracy: 10,
          stationaryRadius: 20,
          distanceFilter: 30,
          debug: false, //  enable this hear sounds for background-geolocation life-cycle.
          stopOnTerminate: false
      };

      this.backgroundGeolocation.configure(config)
      .subscribe((location: BackgroundGeolocationResponse) => {

      console.log('location', location, location.bearing, location.speed, location.longitude);

      this.zone.run(() => {
        this.lat = location.latitude
        this.lng = location.longitude
        this.bearing = location.bearing
        this.speed = location.speed
        this.accuracy = location.accuracy
        this.timestamp = location.time
      })


      this.backgroundGeolocation.finish(); // FOR IOS ONLY

      });

    //foreground tracking

      let options: GeolocationOptions = {
        timeout: 300000,
        enableHighAccuracy: true
      };

      this.watch = this.geolocation.watchPosition(options).filter((p: any) => p.code === undefined).subscribe((position: Geoposition) => {

         console.log(position);

         // Run update inside of Angular's zone
         this.zone.run(() => {
           this.lat = position.coords.latitude;
           this.lng = position.coords.longitude;
           this.speed = position.coords.speed;
           this.accuracy = position.coords.accuracy
         });

         console.log(this.lat, this.lng , 'this is the lat lng')
       });

      this.backgroundGeolocation.start();
      }

    getGPSData(){

    this.gpsunsub = this.service.sendGPS(GPSobjectshere).subscribe(result => {

              }

            }


    }

    stopTracking() {
      this.backgroundGeolocation.stop();
      console.log('stopped tracking')
      this.watch.unsubscribe();
      this.getGPSData()
      this.gpsunsub.unsubscribe()
     }

app.component.ts

    constructor(){
     this.sendGPSStart()
     this.interval()
    }

    sendGPSStart(){
        this.locationTracker.startTracking();
      }

      sendGPSStop(){
        this.locationTracker.stopTracking();
    }

    interval(){
    setInterval(() => {
           this.sendGPSStart()
              this.sendGPSStop()
        }, '30000')

    }

Posts: 1

Participants: 1

Read full topic

Property subscribe does not exist on type '(term:string) => Observable'

$
0
0

@jeandemagny wrote:

I get the data from my server like so :slight_smile:

  private allData(input:string): Observable<any> {
        let params = new HttpParams().set('q', input);
        return this.httpClient.get(Configuration.getData(url), { params: params });
    }

    public getDataService(){
        return this.dataService = (term: string) => this.allData(term);
    }

and in my controller, i would like to check the status of the request above to execute a specific UI action. Here is how i subscribe my data:

this.getDataService().subscribe(
      res => this.httpData = res.results,
      err => console.warn(err),
      () => {
        this.loading.dismiss() /*close loader*/
      }
  )

I have this error :“Property subscribe does not exist on type ‘(term:string) => Observable’”

Any help :slight_smile: ?

Posts: 2

Participants: 2

Read full topic

Enable-menu-with-back-views="true" not working :(

$
0
0

@cpigusch wrote:

When I navigate back to my home page my ion-menu icon goes away, what to do?

<ion-menu [content]=“content” side=“right” enable-menu-with-back-views=“true”>

<ion-toolbar>
    <ion-icon name="add" menuClose (click)="load()"></ion-icon>
  <!--<ion-title>Menu</ion-title>-->
</ion-toolbar>
{{p.title}}

<ion-nav [root]=“rootPage” #content swipeBackEnabled=“false”>

Posts: 2

Participants: 1

Read full topic

Alguien me ayuda con esto , nose que pasa , soy nuevo

Array in reverse order

$
0
0

@Faizyfaazz wrote:

In my ionic project i display some data from native storage.it displays in first in first order.i want to display that in last stored data at first.

  <ion-card *ngFor="let asd of FullDetails; let k=index" style="border: 2px solid #9D9D9D;border-radius: 10px" >
<ion-card-content >
      <p style="font-size: 22px;">{{airline_name[k]}}</p>
      <div class="row" style="border-bottom:0px">
        <div class="col" style="font-size: 25px;width: 25%">{{departure_fscode[k]}}</div>
        <div class="col" style="padding-top: 10px;width: 50%!important;"><img src="assets/statusicon/arrive_onTime.png"></div>
        <div class="col" style="text-align: right;font-size: 25px;width: 25%">{{arrival_fscode[k]}}</div>
      </div>
      <label style="padding-left: 40px;color: #008000">{{asd.status | statusupdator}}</label><label style="padding-right: 5px;padding-left: 5px;">-</label><label>departs in 2 hr 4mins</label>

Posts: 3

Participants: 3

Read full topic

Viewing all 49086 articles
Browse latest View live


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