Quantcast
Channel: Ionic Forum - Latest topics
Viewing all 71015 articles
Browse latest View live

Structuring an ionic 3 Firebase app

$
0
0

@obinnae wrote:

Can someone advice me on the best (or at least, a good) approach for an app that gets data from Firebase? My typescript/angular knowledge is a bit fuzzy, so bear with me.

Here’s my current scenario. An Ionic 3 app for buying/selling stuff. I have individual class files, such as …

export class Product
{
    id: number = new Date().getTime();
    name : string;
    // ... and so on
}

a service file (functions.ts) with all the functions (dozens of them) used on the app, one of the functions is like so …

 getProduct(id):Observable<Product>
 {
   return Observable.create(observer=>
   {
     console.log("id passed: ", id);
     firebase.database().ref('/products/'+id).once('value')
       .then((req)=>{observer.next(req.val())})
       .catch((err)=>{console.log(err)})
   });
 }
/// ... and lots more

then in the other pages, I do something like

import { myfunctions } from '../../providers/functions';
...
constructor(private myfuncs: myfunctions .... )
....
var prod;
this.myfuncs.getProduct(5).subscribe((p:Product)=>
{ prod = p;}

I’m not sure this is the best approach. I’m not too fund of the idea of importing the functions file in every page - I’d rather have each class contain its relevant functions (create(), edit(), delete(),…)

Ideally, I’d like to do something like this …

For the class (dunno if the syntax is correct. Please let me know)

export class Product
{
    id: number = new Date().getTime();
    name : string;
    // ... and so on

   constructor(id:number = null)
   {
    firebase.database().ref('products/' + id).once('value')
            .then((req)=>{return req.val();})
            .catch((err)=>{console.log(err)})
   }

  createProduct(newprod:Product)
  {  // add product to firebase  }

  deleteProduct(id:number)
  { // delete from firebase}

  // ...etc
}

then in other pages…


let prod = new Product(1) //returns the product with ID of 1

Is this a good approach, or can someone suggest a better one, or point me in the right direction? Thanks.

Posts: 1

Participants: 1

Read full topic


Analyse ionic vendor.js

$
0
0

@fabricia77 wrote:

How to analyse ionic vendor.js file.

I tried source-map-explorer but i always got unable to find a source map

Posts: 1

Participants: 1

Read full topic

AngularJS IsDevMode() true when getting update via Ionic Pro builds

$
0
0

@crucialexams wrote:

I have monitoring implemented in Ionic but I get errors from my local development as well as from production. I can remove the code while developing but that’s inconvenient. To fix this I added IsDevMode() from angular to check if dev mode is enabled before logging the exception inside my ErrorHandler. This works as expected when debugging and returns false when running with --prod. So it seemed to work…

However after committing the code and getting an update via build IsDevMode returns true again… meaning everyone who downloads an update via Ionic Pro is for some reason in angular development mode.

Any ideas how to solve this? I’ve tried Googling and searching the forums but can’t seem to find anyone with the same issue.

Thanks!

Posts: 1

Participants: 1

Read full topic

Problem in local image with Photo Viewer

$
0
0

@nahuelreymundo wrote:

Hi!, i’ve install photo viewer native plugin in my app.
But the local image storaged in assets/img/my_image.jpg Doesn’t appear in my app
im using this:
zoom(){
this.photoViewer.show(’…/assets/imgs/my_image.jpg’);
}

what’s the problem?
I need another plugin?

Posts: 1

Participants: 1

Read full topic

Template parser error while using a component inside a page

$
0
0

@ssyedmo wrote:

Hi Guys,

I am trying to create a new custom component in ionic and trying to use it in the ionic page.

I have created a component like

import { Component } from ‘@angular/core’;

/**

  • Generated class for the ImageuploadComponent component.
  • See https://angular.io/api/core/Component for more info on Angular
  • Components.
    */
    @Component({
    selector: ‘imageupload’,
    templateUrl: ‘imageupload.html’
    })
    export class ImageuploadComponent {

text: string;

constructor() {
console.log(‘Hello ImageuploadComponent Component’);
this.text = ‘Hello World’;
}

}

I am importing the component in app.module.ts and setting the ImageuploadComponent in the declarations.

then I tried using the selector ‘imageupload’ in the ionic page as

This is breaking the page and showing me the error as

ncaught Error: Template parse errors:
‘imageupload’ is not a known element:

  1. If ‘imageupload’ is an Angular component, then verify that it is part of this module.
  2. To allow any element add ‘NO_ERRORS_SCHEMA’ to the ‘@NgModule.schemas’ of this component. ("[ERROR ->]"): ng:///TruckpictureuploadPageModule/TruckpictureuploadPage.html@0:0
    at syntaxError (compiler.js:485)
    at TemplateParser.parse (compiler.js:24668)
    at JitCompiler._parseTemplate (compiler.js:34621)
    at JitCompiler._compileTemplate (compiler.js:34596)
    at compiler.js:34497
    at Set.forEach ()
    at JitCompiler._compileComponents (compiler.js:34497)
    at compiler.js:34367
    at Object.then (compiler.js:474)
    at JitCompiler._compileModuleAndComponents (compiler.js:34366)

I am stuck on this from long hours. Please help on this !!!

Posts: 1

Participants: 1

Read full topic

Error on ionic installation

$
0
0

@Asma-M65 wrote:

hi everybody
am new in ionic ,while installation on win 10 , i got these warns:

C:\WINDOWS\system32>npm install -g ionic
C:\Users\Ghavam\AppData\Roaming\npm\ionic -> C:\Users\Ghavam\AppData\Roaming\npm\node_modules\ionic\bin\ionic
npm WARN **rollback Rolling back node-pre-gyp@0.10.0 failed** (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\Ghavam\AppData\Roaming\npm\node_modules\ionic\node_modules\fsevents\node_modules'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\ionic\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ ionic@3.20.0
updated 2 packages in 42.737s

how to fix it guys ?

Posts: 1

Participants: 1

Read full topic

Help with Placing markers on Map

$
0
0

@sayomiola wrote:

Hello,

I am trying to place markers with text on it on a map based on locations and labels from a collection, the map displays but the markers don’t show

Please help

Here is my map.ts

import { Component, ViewChild, ElementRef } from '@angular/core';
import { IonicPage, ViewController, NavController } from 'ionic-angular';
import { RestProvider } from '../../providers/rest/rest';
declare var google;
@IonicPage()
@Component({
  selector: 'page-map',
  templateUrl: 'map.html',
})
export class MapPage {
  @ViewChild('map') mapElement: ElementRef;
  map: any;
  places: any;
    constructor(public navCtrl: NavController, public viewCtrl: ViewController, public restProvider: RestProvider) {
    this.getPlaces();
  }

  // map 
  getPlaces() {
    this.restProvider.getPlaces()
      .then(data => {
        this.places = data;
        if (this.places) {
          for (let element of this.places) {
            var marker = new google.maps.Marker({
              position: { lat: parseFloat(element.Latitude), lng: parseFloat(element.Longitude) },
              title: element.message.substring(0, 30),
              visible: true,
              map: this.map              
            });
            console.log(element);
          };
          //this.directionsDisplay.setMap(this.map);
        }
      });
  }
  alts = this.getPlaces();
  ionViewDidLoad() {

    this.initMap();
  }

  async  initMap() {
    console.log(this.places);

    this.map = new google.maps.Map(this.mapElement.nativeElement, {
      zoom: 14,
      center: { lat: 6.57499666666667, lng: 3.355785 }
    });
  }

  goTo(page) {
    this.navCtrl.push(page);
  }



}

here is the result I get

Posts: 1

Participants: 1

Read full topic

Ionic3+ drawing tools


Ionic cli v3 and v4 global in parallel on a mac?

$
0
0

@reedrichards wrote:

Do anyone knows if it’s possible to install two Ionic cli, the 3 and 4, in parallel on a mac?

If I did understand, installing the cli 4 (rc right now) is the way to begin to have fun with Ionic v4. On the other side, I would like to stick to cli 3 for daily business and current development of my productive app

Any thoughts?

I mean both

 npm i -g ionic
 npm i -g ionic@rc

Posts: 2

Participants: 1

Read full topic

Ngx-translate: where to define translation assets

How to make an authenticated request to Shopify?

$
0
0

@ziaionic wrote:

Dear all !
I want to fetch customers from Shopify store to ionic service,
I sent a get request to Shopify using postman, there is not problem, I chose authorization type: Basic Auth

My question is how to format this request in ionic?
Please help me

postman screenshot

Posts: 1

Participants: 1

Read full topic

Ionic native geolocation not working

$
0
0

@ansarikhurshid786 wrote:

Hi,
I am tried to get user’s current location. In ios working fine but in android if location(GPS) is off i am not getting any error.

is there any way to check location(GPS) is ON or not?

Posts: 1

Participants: 1

Read full topic

Ionic3 - How to send a data from HomePage to another ts file through ShareProvider

$
0
0

@fdggfhgffsdfsf wrote:

I don’t understand how to passe a click button data to another ts file by using a providers file.
So i want to control 4 share button by from home.html, i’m trying to pass the data from the home.html -> home.ts -> Popovershare.ts
I added a share button inside a square button thanks to a poppvers.
And when i try to call the home function directly to popovers.ts “constructor(here)” i got several errors.

This is my home.html
        <button icon-only  (click)="click(1)">
        <button icon-only  (click)="click(2)">
        <button icon-only  (click)="click(3)">
        <button icon-only  (click)="click(4)">
This is my home.ts
 click(myEvent) {
    
        this.indexNumber = myEvent
    
        let numbr_select
    
        if (this.indexNumber == 1) {
          numbr_select = 1
        }
        if (this.indexNumber == 2) {
          numbr_select = 2
        }
        if (this.indexNumber == 3) {
          numbr_select = 3
        }
        if (this.indexNumber == 4) {
          numbr_select = 4
        }
        }
        this.indexNumber =  numbr_select
     
         this.shareprovider.ValueFonction(this.indexNumber)
    
        let popover = this.popoverCtrl.create(PopoversharePage, {
         
        }, {
          cssClass: 'csspopover'
        });
        popover.present({
          ev: myEvent
        });
      }

this is my shareprovider.ts



      template: `
     
    
          <ion-grid>
    ... share button with (click)="shareclick()"
          </ion-grid>
    
      constructor() {
        this.ValueFonction()
      }
      ValueFonction(Number_selected?: any) {
        for (let i = 1; i < 7; i++) {
          if (Number_selected == i) {
            //    console.log(Number_selected, 'Valeur')
          }
        }
        return Number_selected
      }

And this is my Popovershare.ts


    let i
    for (let i = 0; i < 5; i++) {
      switch (i) {
        case 0:
          this.ShareProvider.ValueFonction(1)
          alert(1)
          break;
        case 1:
          this.ShareProvider.ValueFonction(2)
          alert(2)
          break;
        case 2:
          this.ShareProvider.ValueFonction(3)
          alert(3)
          break;
        case 3:
          this.ShareProvider.ValueFonction(4)
          alert(4)
          break;
      }
    }

In these codes, it show in the console the number that i assigned for each button but when i try to call from popovers.ts to shareprovider.ts with this

this.ShareProvider.ValueFonction(4) all alert run at the same time, i don’t understand why.

I just want to control the `hareclick() but this button is in another file ts, hope you understand.

Thanks for your attention !

Posts: 1

Participants: 1

Read full topic

Error when generating production build

$
0
0

@cemansilla wrote:

I’m stuck with an error that I can not solve. Tell me if you need me to show you another file or configuration, I’ll be pending since I need to resolve it ASAP.

The error started when trying to create the build with –prod, I was fixing, updating dependencias and currently when executing ionic cordova build android --prod --verbose I get:

typescript error
‘ion-icon’ is not a known element: 1. If ‘ion-icon’ is an Angular component, then verify that it is part of
this module. 2. If ‘ion-icon’ is a Web Component then add ‘CUSTOM_ELEMENTS_SCHEMA’ to the
@NgModule.schemas’ of this component to suppress this message. ("> <button ion-button icon-only
color=“white” (click)=“openSearchModal()”> [ERROR ->]
")

‘ion-buttons’ is not a known element: 1. If ‘ion-buttons’ is an Angular component, then verify that it is
part of this module. 2. If ‘ion-buttons’ is a Web Component then add ‘CUSTOM_ELEMENTS_SCHEMA’ to the
@NgModule.schemas’ of this component to suppress this message. (" [ERROR ->] <button ion-button icon-only color=“white”
(click)=“openSearchModal()”> ")

‘ion-col’ is not a known element: 1. If ‘ion-col’ is an Angular component, then verify that it is part of
this module. 2. If ‘ion-col’ is a Web Component then add ‘CUSTOM_ELEMENTS_SCHEMA’ to the ‘@NgModule.schemas
of this component to suppress this message. (" [ERROR
->] <button ion-button icon-only color=“white” (click)=“ope”)

Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
at C:\Users\ceman\Desktop\idem-app-updated-master\node_modules@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
at step (C:\Users\ceman\Desktop\idem-app-updated-master\node_modules@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
at Object.next (C:\Users\ceman\Desktop\idem-app-updated-master\node_modules@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
at fulfilled (C:\Users\ceman\Desktop\idem-app-updated-master\node_modules@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
[ERROR] Command not found: ionic-app-scripts
ionic:cli-framework:utils:process onBeforeExit handler: process.exit received +0ms
ionic:cli-framework:utils:process onBeforeExit handler: running 1 queued functions +0ms
ionic:cli-framework:utils:process onBeforeExit handler: exiting (exit code 127) +0ms

These are my files, tell me if you need to see another:

app.module.ts: https://pastebin.com/TXQ4tDFM

package.json: https://pastebin.com/kAK5eK5Z

This is my configuration according to ionic info:

Ionic:

ionic (Ionic CLI)  : 4.0.0-rc.9 (C:\Users\ceman\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework    : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.10

Cordova:

cordova (Cordova CLI) : not installed
Cordova Platforms     : android 7.1.0

System:

Android SDK Tools : 26.1.1
NodeJS            : v6.14.3 (P:\nodejs\node.exe)
npm               : 6.1.0
OS                : Windows 10

Environment:

ANDROID_HOME : P:\Android\sdk

I add an extra data, I had updated to Node 8 to see if this corrected something and nothing, I returned to version 6.

Thanks for any help!

Posts: 1

Participants: 1

Read full topic

Put an image in a toast

$
0
0

@yvancoyaud wrote:

Hello everyone,

I can not find, on the web, an explanation allowing me to add an image in a toast with ionic 3.
Someone to him a link to a tutorial on the customization of the toast, or a piece of code or just a little explanation.
Merci
YC

Posts: 1

Participants: 1

Read full topic


Audio selection refresh

$
0
0

@amin9 wrote:

I’m using audio plugin https://arielfaur.github.io/ionic-audio/2.0/index.html
Similar to the second tab of their demo.

I can play any item using its index, like:

this._audioProvider.play(index);

now I want to stop any item by index. like:

this._audioProvider.stop(index);

but its not working. The slider is not resetting, so, when I play again its continue from the last time.

or
is there a way to reset all audio.

Posts: 1

Participants: 1

Read full topic

FCM push notification icon: any way to automate this process?

$
0
0

@akoyano wrote:

Hello friends.

I am using FCM push notification and it is showing my predefined icon correctly on Android. However, I am not quite comfortable because I had to add my “push icon” manually in “android/res” folder. It means, if I have to remove android platform (and add that again), I gonna lose those icons.

I am wondering if is there an automated way to handle this? (using CLI would be great as we do for “app icon” and splash).

Posts: 1

Participants: 1

Read full topic

How to get nested data in the response of a Json WebService?

$
0
0

@ioclaudio wrote:

Hi,
I’ve a web service that returns this json:

{
    "Response": "Success",
    "Message": "Coin list succesfully returned! This api is moving to https://min-api.cryptocompare.com/data/all/coinlist, please change the path.",
    "BaseImageUrl": "https://www.cryptocompare.com",
    "BaseLinkUrl": "https://www.cryptocompare.com",
    "DefaultWatchlist": {
        "CoinIs": "1182,7605,5038,24854,3807,3808,202330,5324,5031,20131",
        "Sponsored": ""
    },
    "SponosoredNews": [
        {
            "id": 907274,
            "guid": "https://goo.gl/x2wT5k",
            "published_on": 1530020965,
            "imageurl": "https://www.cryptocompare.com/media/34077391/onlineio200x200.gif?anchor=center&mode=crop&width=300&height=300&rnd=131744945650000000",
            "title": "Online.io - Earn Tokens to Browse The Internet",
            "url": "https://goo.gl/x2wT5k",
            "source": "CryptoCompare",
            "body": "Online.io is implementing a decentralized ecosystem which combines all necessary features for a faster, safer, and more private Internet browsing. Moreover, through the Online.io platform developed by using the most advanced Blockchain technology, both internet end users and website operators will benefit alike.\r\n\r\nThe Online (OIO) token is a unique digital asset that will unleash the Internet from ads, malware and tracking software, leading to a more enjoyable and secure browsing experience, with sizeable benefits for both web operators and end users.",
            "tags": "ICO",
            "categories": "ICO",
            "lang": "EN",
            "source_info": {}
        }
    ],
    "Data": {
        "42": {
            "Id": "4321",
            "Url": "/coins/42/overview",
            "ImageUrl": "/media/12318415/42.png",
            "Name": "42",
            "Symbol": "42",
            "CoinName": "42 Coin",
            "FullName": "42 Coin (42)",
            "Algorithm": "Scrypt",
            "ProofType": "PoW/PoS",
            "FullyPremined": "0",
            "TotalCoinSupply": "42",
            "PreMinedValue": "N/A",
            "TotalCoinsFreeFloat": "N/A",
            "SortOrder": "34",
            "Sponsored": false
        },
        "300": {
            "Id": "749869",
            "Url": "/coins/300/overview",
            "ImageUrl": "/media/27010595/300.png",
            "Name": "300",
            "Symbol": "300",
            "CoinName": "300 token",
            "FullName": "300 token (300)",
            "Algorithm": "N/A",
            "ProofType": "N/A",
            "FullyPremined": "0",
            "TotalCoinSupply": "300",
            "PreMinedValue": "N/A",
            "TotalCoinsFreeFloat": "N/A",
            "SortOrder": "2212",
            "Sponsored": false
        },
......

I have to print the Name and TotalCoinSupply of each Data item?

I’m using this function into a Providers to get the data using HttpClient:

  getCoinList() {
    return new Promise(resolve => {
      this.http.get(this.apiUrlCrypto+'/coinlist',{headers: this.cryptoHeaders}).subscribe(data => {
        resolve(data);
      }, err => {
        console.log(err);
      });
    });

and this function in a Ionic page to call the provider function:

  getCoins(){
    console.log('getCoinsList');
    this.users = [];
    this.coins = [];
    this.wsManager.getCoinList()
      .then(data => {
        this.coins = data;
      });
  }

I don’t know how to navigate the content of the attribute this.coins and how to
check its content.

cld

Posts: 2

Participants: 2

Read full topic

Reading Ion Grid Data

$
0
0

@Aryan561 wrote:

Hi Team,

I need small idea on ion-grid

after reading the entire component of ion-grid, i designed it but while trying to save data i couldn’t able to get idea of how to read ion-grid all rows at once.

i’ve found other ways of reading them… but on clicking of one button which is outside of ion-grid

can i read all rows at once and build Json Object?

Posts: 2

Participants: 2

Read full topic

Firebase Storage With Ionic Creator

$
0
0

@sim1138 wrote:

How exactly would you allow users to upload images in an Ionic Creator app, then store that image in Firebase Storage and save the link to that image in a Firebase Database at the same time?

Posts: 1

Participants: 1

Read full topic

Viewing all 71015 articles
Browse latest View live


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