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

Using event.preventDefault to prevent ion-toggle to toggle

$
0
0

@tanmay_patil wrote:

I am using ion-toggle in my app . when user clicks(checks) on the ion-toggle , i have written ionChange hook on the ion-toogle . In this hook ,due to application logic , i am giving prompt to the user saying ion-toggle can not be set .

using event.preventDefault to prevent ion-toggle to toggle

component html

<ion-content padding>
     <ion-slides pager="true">
    <ion-slide *ngFor="let giftSlide of giftsAllMatrix" >
    <ion-row *ngFor="let giftRecord of giftSlide">
      <ion-col *ngFor="let giftCol of giftRecord" col-6>
        <img src="./assets/{{giftCol.giftImage}}" >
          <p> gift code :  {{ giftCol.giftCode }} </p>
          <ion-item>
         <ion-toggle   #giftSelect (ionChange)="onGiftSelect(giftCol.giftCode, giftCol.pointsRequired ,giftCol.giftImage,giftSelect.checked,giftSelect,$event)" checked="false"></ion-toggle>
          </ion-item>
        </ion-col>
    </ion-row>
    </ion-slide>
    </ion-slides>

component hook - onGiftSelect

onGiftSelect( giftSelCode : string ,
           pointsRequired : number ,
           giftImage : string ,
            selected : boolean
           ,giftSelect : any,
           event : Event)
      {
         console.log("inside onGiftSelect "+giftSelCode);
         console.log("inside onGiftSelect  points required "+pointsRequired);
         console.log(" selected "+selected );
         console.log(" this.giftSelectedFlg "+this.giftSelectedFlg );
         let navigate = true;
         // if ion-toggle is true then only navigate
         // when toggle is from 'selected' to 'deselected' do not
         if ( selected === true)
         {
            if ( this.giftSelectedFlg  === false )
            {
                this.giftSelectedFlg = true;
            }
            else
            {

                if(isProdSetup() === true)
                {
                    this.toast.show( "Select one gift at time ", '3000', 'center').subscribe
                    ( toast =>
                    {
                        console.log(toast);
                    });
                }
                else
                {
                     let alert = this.alertCtrl.create({
                     title: 'Gift selection',
                     subTitle: 'Multiple gift selection disallowed',
                     buttons: ['Dismiss']
                     });
                     alert.present();
                }
              navigate = false;
              event.preventDefault();
        }
         if ( navigate)
        {
           // Pass the control to giftSelect page
           this.navCtrl.push("Giftselect",
              {
                 giftCode : giftSelCode ,
                 pointsRequired : pointsRequired ,
                 giftImage : giftImage
              });
         }

    }

using viewchild

using nativeElement

this code also does not work . Can anybody help me to get right way to prevent ion-toggle component prevent toggling in ionChange event.

 export class Giftfactory {
      giftsAllMatrix : GiftCatalogueEntry[][][];
      gifts : Array<any> ;
      totalPoints : number = 0;
      error : string;
      giftSelectedFlg : boolean = false;
      giftChoice : any;
      //giftSelect :  any; //template variable.
     @ViewChild ('giftSelect') gtSel ;

onGiftSelect( giftSelCode : string ,
           pointsRequired : number ,
           giftImage : string ,
            selected : boolean
           ,giftSelect : any,
           event : Event)
    {
    ...
        // trying to uncheck ion-toggle - does not work
        this.gtSel.nativeElement.checked = false;
    }

Posts: 1

Participants: 1

Read full topic


Camera plugin won't run in iOS

$
0
0

@achaheen wrote:

Hi,

I'm using ionic latest version to build an application with the ability to take photos using device camera. I was able to run this application successfully in android emulator and real device, but in iOS when I click the button to start the camera it gives this error:

2017-07-02 14:14:32.130 MyApp[4440:59777] Camera.getPicture: source type 1 not available.
2017-07-02 14:14:32.136 MyApp[4440:59725] error getting image: No camera available

I am able to select photos from the library in iOS but the camera never asks for the permission and never start.

This is the Github repo for my project.

Hi,

I'm using ionic latest version to build an application with the ability to take photos using device camera. I was able to run this application successfully in android emulator and real device, but in iOS when I click the button to start the camera it gives this error:

2017-07-02 14:14:32.130 MyApp[4440:59777] Camera.getPicture: source type 1 not available.
2017-07-02 14:14:32.136 MyApp[4440:59725] error getting image: No camera available

I am able to select photos from the library in iOS but the camera never asks for the permission and never start.

Posts: 1

Participants: 1

Read full topic

Add a back button on input box

Checkboxes do not "exist" until ticked!

$
0
0

@SubEffect wrote:

I'm iterating over an array with for.. of. The array contains the true/falses from a checkbox array.

I'm finding that the array is empty until the checkbox is ticked. They are initialised like this:

<ion-checkbox color="primary" checked="false" *ngIf="listitem.flavour === 'item'" [(ngModel)]="item_ticks[i]" (ionChange)="updateTicks()"></ion-checkbox>

As you can see, checked is already set to "false" so why is the ngModel item_ticks empty (null) until the checkboxes are checked?

Posts: 2

Participants: 2

Read full topic

How to create a backspace button in ionic

$
0
0

@vithika wrote:

I want to create a backspace button in ionic when clicking on that button the length of the string should reduce by one..

I tried the following--

clear()
{

this.value=this.value.length-1;
}

but in this case the output is the length of the value minus one,
like if input is 123 ,I am getting output on clicking the button as 2(length=3-1)
as ,my output..
Please help if anyone has tried this out..
Thanks,,

Posts: 1

Participants: 1

Read full topic

After deeplinks, two-way-binding is not working (Test code exist)

$
0
0

@Taehwa wrote:

I have an issue with deeplinks which blocks angular's two-way-binding.

I made a test project in git. Please check here (This is a simple ionic default project. If you have already installed npm and ionic-cli, just run npm i, ionic cordova platform add ios)

Explain about the project
1. Working case

  • There are 3 pages. Home, List and Modal.
  • Each pages have an input and this input's variable is connected
    with test variable. And this test is shown just under the input

Like:

<input (input)="testFn($event)" name="myTest">
<p>Hello {{test}}!</p>
  • Every page, whenever I type in the input, it immediately reflects in
    {{test}}.
  • Everything seems ok.

2. Not working case

  • If you check app.component.ts, you will see deeplinks is set as
    this.nav.push('ListPage'); and the url is myapp://list

  • So in my xcode iphone emulator, I will open safari and type in the address bar as myapp://list. It will redirect you to the List page.

  • Since then, type in the input to reflect to {{test}} is not working in the List page and the Modal page. But working in the Home page.
  • In testFn function, I put console.log. When I test, console.log always prints properly. So I guess angular is not updating properly.
    ( If you don't see keyboard in xcode iPhone emulator : cmd + shift + k )

My environment

  • Ionic Framework: 3.5.0
  • Ionic App Scripts: 1.3.12
  • Angular Core: 4.1.3
  • Angular Compiler CLI: 4.1.3
  • Node: 7.10.0
  • OS Platform: macOS Sierra
  • Navigator Platform: MacIntel
  • User Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1
  • Xcode : 8.3.3 (8E3004b)
  • Emulator : iPhone 5 iOS 10.3 (14E8301)

I tried also ionic cordova platform rm ios and ionic cordova platform add ios but no luck.

Can anyone tell me what is wrong with my code?

Thank you very much.

Posts: 1

Participants: 1

Read full topic

How to work on youtube api on ionic 2

$
0
0

@abomusab wrote:

Hi ,
I'm working on project which need me to get the current time in youtube video and some other stuff

anyone has youtube api library which let me take this stuff please?

Posts: 1

Participants: 1

Read full topic

View child not working ionic3

$
0
0

@anivaishu wrote:

Hi all,

I am using ionic 3 with animations.

I installed

npm install --save css-animator

Here is my Template

<div class="alert" *ngIf="!show" #myElement>
  <h5>Here is my animation</h5>
</div>

<ion-footer>
  <ion-row ion-button class="btn-full" *ngIf="show">
    <ion-col text-left (click)="nav()">
        Checkout   <ion-icon name="cart"></ion-icon>
    </ion-col>
    <ion-col text-right>
        <img src="./assets/images/rupee-black.svg" alt="Rupee">4200
    </ion-col>
  </ion-row>
</ion-footer>

I declare variable and the name is show also import view child

 import { Component,ViewChild } from '@angular/core';
import { AnimationService, AnimationBuilder } from 'css-animator';

export class CartPage {

show:boolean=true;
@ViewChild('myElement')myElem;
private animator: AnimationBuilder;
constructor(animationService: AnimationService,public navCtrl: NavController, public navParams: NavParams) {
    this.animator=animationService.builder();
  }

  nav()
  {
    var i=document.querySelector('alert');
  	this.show=false;
    this.animator.setType('bounce').show(this.myElem.nativeElement);
  }

 }

I am getting this error.

Cannot read property 'nativeElement' of undefined

How can i fix this issue.

Kindly advice me,

Thanks

Posts: 1

Participants: 1

Read full topic


Dynamic button color change using click event on specific button

$
0
0

@ismailcse11 wrote:

html

<ion-item>
	<button ion-button [outline]="isOutline" small *ngFor="let sizeList of sizeData" (click)="sizeStore($event,sizeList.id)">{{sizeList.size_name}}</button>
</ion-item>

ts file
--

sizeStore(event,val){
		this.isOutline=true;
	}

output


this code is working for all button. but i want to use for specific item not all.
Please any body help. Thanks in advanced.

Posts: 1

Participants: 1

Read full topic

Redirect to login page if response status 401

$
0
0

@EmanShaaban wrote:

I want to redirect the user to login page if the status of the response from the api is 401

I'm trying to handle the case of the expired token, the api will respond with 401 response status to the ionic app, the problem is that I can't get the the json object of this response to check for the status so that I can redirect to the login page.

Posts: 1

Participants: 1

Read full topic

How to create a new module

$
0
0

@Java_Programming wrote:

Hi, I am learning to program apps with ionic. There are a few things I don't understand at the moment:
In angularJS you can create a module by "angular.module("name", [])" and then set a controller by ".controller("ctrl", function($scope){

})"

First of all: Where do I create such a module in my Ionic project?
2. How can I gain access to the module in another .ts file
3. Is there a big difference between declaring a module in Javascript and in Typescript?

I am sorry if some of the questions are stupid...
Thanks for helping!

Posts: 1

Participants: 1

Read full topic

Cache images coming from Firebase Storage

$
0
0

@xerri wrote:

I would like to cache image coming from Firebase Storage but the info online is a bit confusing. A lot of tutorials show the use of Cordova File and Cordova File Transfer. Why not ionic/storage and save the image in base64 using btoa()? Note that the CORS issue from Firebase exists and this is the only way to get around it: https://stackoverflow.com/questions/37760695/firebase-storage-and-access-control-allow-origin/37765371#37765371. Is it possible to cache image from Firebase Storage for apps running in the browser, iOS and Android? Anyone handled this issue?

This is my ionic info.

Cordova CLI      : 7.0.1
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.2.3 ios 4.3.1
Ionic Framework                 : ionic-angular 3.4.0

System:

Node       : v6.10.2
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.1
ios-sim    : 5.0.13
npm        : 5.0.3

Posts: 1

Participants: 1

Read full topic

Display call log details in ionic

$
0
0

@vithika wrote:

I want to display the call log details from the phone to my app,how can I use this..
I read about call-log plugin,,,but I am confused how to use it in my app..Please help me with this..If anyone has tried this,please share your code,as I am new to this..

Posts: 1

Participants: 1

Read full topic

Following errors appears after upgrading

$
0
0

@rsa wrote:

I only used update command to upgrade project dependencies , the following error happens to me.


Typescript Error
Class 'Nav' incorrectly extends base class 'NavControllerBase'. Types of property 'goToRoot' are incompatible. Type '(opts: NavOptions) => Promise<any>' is not assignable to type '(opts: NavOptions) => Promise<never>'. Type 'Promise<any>' is not assignable to type 'Promise<never>'. Type 'any' is not assignable to type 'never'.
e:/apps/node_modules/ionic-angular/components/nav/nav.d.ts
 */
export declare class Nav extends NavControllerBase implements AfterViewInit, RootNode, INav {
    private _root;
Typescript Error
Class 'Tab' incorrectly extends base class 'NavControllerBase'. Types of property 'goToRoot' are incompatible. Type '(opts: NavOptions) => Promise<any>' is not assignable to type '(opts: NavOptions) => Promise<never>'. Type 'Promise<any>' is not assignable to type 'Promise<never>'.
e:/apps/node_modules/ionic-angular/components/tabs/tab.d.ts
 */
export declare class Tab extends NavControllerBase implements ITab {
    private _cd;
Typescript Error
Type 'IterableDiffer' is not generic.
...r_abber/node_modules/ionic-angular/components/virtual-scroll/virtual-scroll.d.ts
private _dom;
_differ: IterableDiffer<any>;
_scrollSub: any;
Typescript Error
Class 'Subject<T>' incorrectly extends base class 'Observable<T>'. Types of property 'lift' are incompatible. Type '<T, R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'. Type 'Observable<T>' is not assignable to type 'Observable<R>'. Type 'T' is not assignable to type 'R'.
e:/apps/node_modules/rxjs/Subject.d.ts
 */
export declare class Subject<T> extends Observable<T> implements ISubscription {
    observers: Observer<T>[];
Typescript Error
Class 'WebSocketSubject<T>' incorrectly extends base class 'AnonymousSubject<T>'. Types of property 'lift' are incompatible. Type '<R>(operator: Operator<T, R>) => WebSocketSubject<R>' is not assignable to type '<T, R>(operator: Operator<T, R>) => Observable<T>'. Type 'WebSocketSubject<R>' is not assignable to type 'Observable<T>'. Types of property 'operator' are incompatible. Type 'Operator<any, R>' is not assignable to type 'Operator<any, T>'. Type 'R' is not assignable to type 'T'.
e:/apps/node_modules/rxjs/observable/dom/WebSocketSubject.d.ts
 */
export declare class WebSocketSubject<T> extends AnonymousSubject<T> {
    url: string;

Ionic Framework: ^3.5.0
Ionic Native: 2.9.0
Ionic App Scripts: 1.3.12
Angular Core: 4.2.5
Angular Compiler CLI: 4.2.5
Node: 8.0.0
OS Platform: Windows 10
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36

Posts: 1

Participants: 1

Read full topic

Is it possible to add objective c code in ionic or accedss js in Xcode from Objc?

$
0
0

@kGopi14 wrote:

Hi All,

I have created the app in ionic framework and sucessfully build in ios. Is it possible to add objective c code in ionic source code or can we call those native methods from Ionic (js). Also i need to add local notification on push message. Please suggest how to make this possible.

How to make communication between Obj c code and JS from XCode? Any solution?

Thanks!

Posts: 1

Participants: 1

Read full topic


Posting to backend by selecting an id in dropdown

$
0
0

@amad4biz wrote:

I have a question how can I post from two entities. Let says I have I created cars post now I want to use the cars post as a drop down and then post report by pulling the categories from my database in ionic 2.

my service

           import { Injectable } from '@angular/core';
           import { Http, Headers } from '@angular/http';
           import 'rxjs/add/operator/map';
          @Injectable()
           export class DataServiceProvider {

         constructor(public http: Http) {
              console.log('Hello DataServiceProvider Provider');
     }



 getCars(){

      return new Promise (resolve =>{
      let headers = new Headers();

     headers.append('Content-Type', 'application/json')

    this.http.get('http://localhost:3000/api/vehicules', {headers: headers})

           .map( res => res.json())
           .subscribe(data => {
               resolve(data)
              // console.log(data)
           })



    })
 }
    addReport(report){

  return new Promise(resolve => {

  let headers = new Headers();
  headers.append('Content-Type', 'application/json');

  this.http.post('http://localhost:8080/api/reports/new', JSON.stringify(report), {headers: headers})
    .subscribe((data) => {
      resolve(data);
    });

    });



  }
  }

my component.html
     import { Component } from '@angular/core';
     import { NavController } from 'ionic-angular';
     import {Validators, FormBuilder, FormGroup } from '@angular/forms';
     import { DataServiceProvider } from '../../providers/data-service/data-service';

    @Component({
       selector: 'page-home',
       templateUrl: 'home.html'
   })
  export class HomePage {

   cars : any;
   selectedCars: any;

  private myForm : FormGroup;

  constructor(public navCtrl: NavController, private data : DataServiceProvider, private formBuilder:
  FormBuilder ) {

 this.getCars()

  this.myForm = this.formBuilder.group({
  address: ['', Validators.required],
  car: [''],
  comment: ['']
});

 }

    getCars(){

       this.data.getCars().then(data=>{

       this.cars = data
        console.log(this.cars)
     })


   }

   onChange(newValue) {
  this.selectedCars = newValue;
  console.log(this.selectedCars);

}


  addReport(){
   console.log(this.myForm.value)

  this.data.addReport(this.myForm).then(data=>{
  console.log('created')
  })
}
}

html component

  <ion-header>
    <ion-navbar>
      <ion-title>
         Ionic Blank
     </ion-title>
     </ion-navbar>
 </ion-header>

 <ion-content padding>
   <h2>Add a Report </h2>
 <br>
 <form [formGroup]="myForm" class="navbar-form navbar-left" (ngSubmit)="addReport()">

    <br>

   <ion-item>

    <ion-select formControlName="car" (ngModelChange)="onChange($event)">

    <ion-option [value]="car._id" *ngFor="let car of cars">{{car.make}} {{car.model}}</ion-option>

</ion-select>
  </ion-item>
     <br>

    <ion-item>
        <ion-label>Addresse</ion-label>
        <ion-textarea formControlName="address"></ion-textarea>
    </ion-item>

  <ion-item>
      <ion-label>Comment</ion-label>
    <ion-textarea formControlName="comment"></ion-textarea>
  </ion-item>

 <br>

<button ion-button type="submit" >Submit</button>

can anyone please assist on how to create this, I am getting an error "ERROR Error: Uncaught (in promise): TypeError: Converting circular structure to JSON
TypeError: Converting circular structure to JSON
at JSON.stringify ()", however i can see the form values in the console. Thank you for any asssitance. below is my ionic info

global packages:

@ionic/cli-utils : 1.4.0
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.12
@ionic/cli-plugin-ionic-angular : 1.3.1
Ionic Framework                 : ionic-angular 3.5.0

System:

Node       : v6.9.1
OS         : Windows 10
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed
npm        : 4.2.0

Posts: 1

Participants: 1

Read full topic

Image in component

$
0
0

@anna_liebt wrote:

Hello,
I made a custom component. In this component I will use for example a image.

Is there a way to add this image to the custom component folder and reference it from this folder.

The idea behind is to store all files, related with this custom component, at one location.

ionic 3.x

Thanks in advance, anna.

Posts: 1

Participants: 1

Read full topic

Component with list

$
0
0

@anna_liebt wrote:

Hello,
I made a component. I can use this component in a list.

How can I make a custom component like list.





And with code I get the childrens for furter doings.
ionic 3.x

Thanks in advance, anna

Posts: 1

Participants: 1

Read full topic

Best solution for call function

Signal Protocol / secure messaging

$
0
0

@urbiwan wrote:

Hi everybody

i like to implement a secure text messing in one of my apps. Since we live in 2017 ( post snowden ) security is an issue. Therefor i like to use the signal protocol ( https://en.wikipedia.org/wiki/Signal_Protocol ).

I like to use either https://github.com/WhisperSystems/libsignal-protocol-javascript or as cordova plugin ( https://github.com/WhisperSystems/libsignal-protocol-java )

My questions :
1. Anyone did this already
2. I could not find any plugin yet. Is there anyone ?

Best regards

Posts: 1

Participants: 1

Read full topic

Viewing all 49234 articles
Browse latest View live


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