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

Header aligns title and icon in a weird way

$
0
0

You don't need any scss...keep your code light :slight_smile:


How to show cordova app on ios default share sheet?

How to validate inputs in edit forms?

$
0
0

I know how to validate, but I don't know how to validate when editing a form!

this is my page.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ToastController, LoadingController } from 'ionic-angular';
import { Api } from '../../providers/api';
import { Toast } from '@ionic-native/toast';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Consumer } from '../consumer/consumer';


@IonicPage()
@Component({
  selector: 'page-addconsumer',
  templateUrl: 'addconsumer.html',
})
export class Addconsumer {

  addForm: FormGroup;
  loader: any;

  id: number;
  firstName: string;
  lastName: string;
  gender: string;
  birth: string;
  phone: number;
  email: string;

  constructor(public navCtrl: NavController, public navParams: NavParams, private api: Api, private toastCtrl: ToastController, public formBuilder: FormBuilder, public loadingCtrl: LoadingController) {

    this.id = navParams.get('id');
    this.firstName = navParams.get("firstName");
    this.lastName = navParams.get("lastName");
    this.gender = navParams.get('gender');
    this.birth = navParams.get('birth');
    this.phone = navParams.get('phone');
    this.email = navParams.get('email');

    this.addForm = formBuilder.group({
      firstName: ['', Validators.compose([Validators.maxLength(5), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
      lastName: ['', Validators.required],
      gender: ['', Validators.required],
      birth: ['', Validators.required],
      phone: ['', Validators.required],
      email: ['', Validators.required]
    });
  }


  saveConsumer(id, firstName, lastName, gender, birth, phone, email) {
    // this.presentLoading();
    // console.log(id);
    if (this.id) {
      this.api.editConsumer(this.id, this.firstName, this.lastName, this.gender, this.birth, this.phone, this.email).subscribe(response => {
        //this.navCtrl.popTo(Consumer, response);
        this.navCtrl.push(Consumer, response);
      });
    } else {
      this.api.addConsumer(this.addForm.value["firstName"], this.lastName, this.gender, this.birth, this.phone, this.email).subscribe(response => {
        //this.navCtrl.popTo(Consumer, response);
        this.navCtrl.push(Consumer, response);
      });
    }
  }

}

and this the page.html :

  <ion-navbar>
    <ion-title>Add or Edit Consumer</ion-title>
  </ion-navbar>

</ion-header>


<ion-content padding>
  <form (submit)="saveConsumer()" [formGroup]="addForm" >
  <ion-list>
    <ion-item>
      <ion-label>Firstname</ion-label>
      <ion-input type="text"   formControlName="firstName"></ion-input>
    </ion-item>

    <ion-item>
  <ion-label>Lastname</ion-label>
  <ion-input type="text" formControlName="lastName" name="lastName"></ion-input>
</ion-item>

<ion-item>
  <ion-label>Gender</ion-label>
  <ion-select formControlName="gender" name="gender">
  <ion-option value="m">Male</ion-option>
  <ion-option value="f">Female</ion-option>
  </ion-select>
</ion-item>

<ion-item>
  <ion-label>Birth</ion-label>
  <ion-input type="date" formControlName="birth" name="birth"></ion-input>
</ion-item>

<ion-item>
  <ion-label>Phone</ion-label>
  <ion-input type="tel" formControlName="phone" name="phone"></ion-input>
</ion-item>

<ion-item>
  <ion-label>Email</ion-label>
  <ion-input type="email" formControlName="email" name="email"></ion-input>
</ion-item>
  </ion-list>

  <button ion-button full type="submit">Save</button>
  </form>

</ion-content>

I can't parse json ajax data

$
0
0

Server side problem :frowning:

PROBLEM? emulator android==>4.3 ionic android==>6.2.2

$
0
0

could be the problem emulator starting wait whitescreen?
emulator android==>4.3
ionic android==>6.2.2

I can't parse json ajax data

$
0
0

Here is my Server side. The header stuff is the important thing:

<?php

/*
 * Collect all Details from Angular HTTP Request.
 */

header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');

$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$echo = $request->echo;

echo '{"echo":"' . $echo . '"}';

Audio in browser

$
0
0

I run npm run ionic:build --prod
This produces a 2.07mb build and runs great in browsers.

When I runionic cordova run browser, it produces a build 12.7mb in size.
Is this what Ionic expects for its purposed PWA advancements?
I saw no mention of having to use ionic cordova run browser to enable NativeAudio in the docs.

When I provide the app to browsers, I do not include Cordova.js. Everything else works but NativeAudio.
You say it is semi-supported. The additional 10mb to include NativeAudio is not a reasonable trade-off.

What is the current alternative for playing sounds in Ionic for browsers.

Ionic Storage problem

$
0
0

With this code I always get the error: All declarations of 'storage' must have identical modifiers'

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';

import {IonicStorageModule} from '@ionic/storage'

@NgModule({
  declarations: [
    MyApp,
    HomePage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot()
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

import { Storage } from '@ionic/storage';

export class MyApp {
  constructor(private storage: Storage) { }

  storage.set('item1', 'item');

  storage.get('item2').then((val) => {
    console.log('Your age is', val);
  });
}

note: I got the code from the ionic docs


Audio in browser

$
0
0

I have not tested against multiple browsers yet but this seems to work so far:
new Audio('assets/sounds/beep.mp3').play();

New ionic-audio plugin for ionic

$
0
0

Hi @tspence, have you got any solution to this? I'm facing the same issue. There should be a way to reinitialize the audioProvider tracks.

Thanks

Ionic 3 API Parsing Error

Ionic with stripe checkout integration(custom)

$
0
0

@repropos Being new to ionic I suppose I am making a lot of errors. I tried for several days to use Ionic Native Stripe. I was able to successfully get the token. However, I ran into a problem and maybe you can help.

I could not figure out how to get the validation functions such as validateCardNumber working with the client-side. For instance, the form should be able to check whether the card number is in valid format before sending to Stripe to get a token. In other parts of the form, I am using the validation examples as given by Josh Morony at

He gives examples on creating a custom validator. I assumed we could use this to include the stripe validators but I was unsuccessful with the format he gave.

Bottom line, can you provide some direction as to how to incorporate the Stripe validators? Do I need to scrap the validation scheme as use an onBlur instead? Any ideas would be helpful as I am stuck.

How to validate inputs in edit forms?

$
0
0

I usually set a flag 'isNewConsumer = true' on calling the AddConsumer page...in that way, I can configure the initial value in the constructor...also, you can create an interface (model) for the Consumer type

consumerModel: Consumer:

constructor(...) {

   this.addForm = formBuilder.group({
      firstName: ['', Validators.compose([Validators.maxLength(5), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
      lastName: ['', Validators.required],
      gender: ['', Validators.required],
      birth: ['', Validators.required],
      phone: ['', Validators.required],
      email: ['', Validators.required]
    });

    if(navParams.isNewConsumer) {
      this.consumerModel = {};
    else {
      this.consumerModel = navParams.editConsumer;
      this.addForm.setValue(this.consumerModel, {onlySelf: true});
    }

  }

Error: Hook failed with error code 127

$
0
0

I removed and reinstalled ios platform. problem solved!

Could not find gradle wrapper within Android SDK. Might need to update your Android SDK

$
0
0

this works.. thanks bro


Image Sharing with special character in URL Fails

$
0
0

When i try to share image with %20 in URL it fails, how do i get rid of it? Cordova SocialSharing Plugin.

URL Example: https://api.backendless.com/df1223ca-9cf4-534c-ff07-fb17e4d58700/v1/files/mega/yellowflat%20(1).jpg

Loading custom HTML from a file?

$
0
0

Hmmm. I realised the problem - I want to DL these docs from Firebase etc.

I've done this before with JSON but I need to do it with these html files.

Eg. If I have the content in a:

var content.html1 = `
<html>

`

Infinite scroll is visible

$
0
0

Thank you, that did work with infinite scroll and does exactly what I want.

Ionic cloud instagram login's access_token?

Cordova camera fails

$
0
0

I keep getting the following error whenever I try to open up my Android camera with Cordova Camera:

"file:///storage/emulated/0/Android/data/com.ionicframework.ionicApp144916/cache/.Pic.jpg exposed beyond app through ClipData.Item.getUri()"

The strange thing is that it works fine when I run ionic run android. It seems like this is an old bug that was supposed to be fixed a year ago - Many of the solutions online involve updated the version of cordova camera or the android platform. I have done this and it still doesn't work. Has anyone ever resolved this problem before?

Thanks.

Viewing all 229549 articles
Browse latest View live


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