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

Steps to create working custom components

$
0
0

These are very totally opposite-of-dumb questions, that expose the fact (IMHO) that there are some parts of the typical Ionic development experience that cross the line from being useful to being “too cute for their own good”.

So some guidelines I have found useful:

  • ground yourself in Angular. go through the Tour of Heroes. yes, it seems long and daunting at first, but it really will contain the answers to 90% of the questions you are going to have.
  • maybe eventually you will find the generators useful. I’ve been working with Ionic for almost 4 years, and I’m yet to hit that point, though. I think there is real value in organizing your project and making the files yourself, because you understand how the pieces fit together and learn to recognize common situations where they aren’t, such as the one you’ve hit here.
  • which leads me to lazy loading. I think it causes way more problems than it solves, especially for non-colossal apps and people who are just starting out. so this is how I would solve your current problem:

A. Generate a new project with the “blank” starter instead of the “tabs” one.
B. Delete every file under src/app/ with module in its name, except for app.module.ts.
C. Replace the import of AppRoutingModule in app.module.ts with:

RouterModule.forRoot([
      {path: '', redirectTo: 'home', pathMatch: 'full'},
      {path: 'home', component: HomePage}
    ])

D. Add HomePage to the declarations stanza of AppModule while you’re there
E. Run ionic serve and make sure the world is your oyster.
F. Stop the ionic serve process
G. Now make a span1 directory and three files in it:

span1.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'my-span1',
  templateUrl: './span1.component.html',
  styleUrls: ['./span1.component.scss'],
})
export class Span1Component {}

span1.component.scss

empty for now, but must exist

span1.component.html

<span>hello world</span>

H. Put a <my-span></my-span> in your app.component.html somewhere
I. Add Span1Component to the declarations stanza of your app module, right next to HomePage.
J. Run ionic serve again and hopefully hello world will appear as well

If you decide instead that you really really want the lazy loading stuff, you are going to have to add MySpan1ComponentModule to the imports stanza of Tab1PageModule. Then you’re going to have to remember to do something similar absolutely every single time you want to use component X in component Y. That should fix things within your existing project, though.


Capacitor App - Barcode scanner issue

$
0
0

That’s all it says? “variables are not declared”?

Filter product by category

$
0
0

When user click Category. It should navigate to the relevant page and show products according to that category.


Plz, refer to the gif. that gif show all items when I click a category. I’m using restFul API

Strange flickering on page change

$
0
0

I have problem with strange flickering on page changed. video here. My project is with tabs. When i try to open child page in tab one the flicker/laggy effect is visible. You can see in the video.
Sory for my broken english.

Ionic CLI                     : 5.4.13 (C:\Users\mitko\AppData\Roaming\npm\node_modules\ionic)

Ionic Framework : @ionic/angular 4.11.10
@angular-devkit/build-angular : 0.803.23
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.1.2
Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : browser 6.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 6 other plugins)

import { Component, OnInit } from '@angular/core';
import { AuthService } from 'src/app/services/auth.service';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { NavController } from '@ionic/angular';

@Component({
  selector: 'app-saloon-info',
  templateUrl: './saloon-info.page.html',
  styleUrls: ['./saloon-info.page.scss'],
})
export class SaloonInfoPage {
  id: string;
  spinnerFlag = true;
  saloonData: Observable<any>;
  employees: Observable<any>;

  constructor(
    private authService: AuthService,
    private route: ActivatedRoute,
    private navCtrl: NavController) { }

  ionViewWillEnter() {
    this.id = this.route.snapshot.paramMap.get('saloonId');

    this.authService.getSaloonInfo(this.id).subscribe(data => {
      this.saloonData = data[0];
      this.employees = data[0].employees;
      console.log(this.employees);
      this.spinnerFlag = false;
    });
  }

  goBack() {
    this.navCtrl.back();
  }
}


<ion-header>
  <ion-toolbar>
    <ion-buttons slot="start">
      <ion-back-button
          [text]="'Назад'"
          [icon]="buttonIcon">
      </ion-back-button>
    </ion-buttons>
  </ion-toolbar>
</ion-header>

<ion-content class="background-image ion-padding">
  <ion-spinner name="lines" *ngIf="spinnerFlag" color="tertiary" class="spinnerCenter"></ion-spinner>
  <ion-card>
    <ion-card-header class="ion-text-center">
      <ion-card-subtitle>{{saloonData?.location}}</ion-card-subtitle>
      <ion-card-title>{{saloonData?.name}}</ion-card-title>
    </ion-card-header>

    <ion-card-content>
      <ion-list *ngIf="employees">
        <ion-item *ngFor="let object of employees" [routerLink]="'calendar-modal//' + object.user_id"
          routerDirection="forward">
          <ion-label>Име: {{object.employee.name}}</ion-label>
        </ion-item>
      </ion-list>
    </ion-card-content>
  </ion-card>
</ion-content>

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TabsPage } from './tabs.page';

const routes: Routes = [
  {
    path: '',
    redirectTo: '/members/tab1',
    pathMatch: 'full'
  },
  {
    path: '',
    component: TabsPage,
    children: [
      {
        path: 'tab1',
        children: [
          {
            path: '',
            loadChildren: () =>
              import('../tab1/tab1.module').then(m => m.Tab1PageModule)
          },
          {
            path: 'saloon-info/:saloonId',
            children: [
              {
                path: '',
                loadChildren: () => import('../tab1/saloon-info/saloon-info.module').then(m => m.SaloonInfoPageModule),
              },
              {
                path: 'calendar-modal/:id',
                loadChildren: () => import('../tab1/calendar-modal/calendar-modal.module').then(m => m.CalendarModalPageModule)
              }
            ]
          }
        ]
      },
      {
        path: 'tab2',
        children: [
          {
            path: '',
            loadChildren: () =>
              import('../tab2/tab2.module').then(m => m.Tab2PageModule)
          }
        ]
      },
      {
        path: 'tab3',
        children: [
          {
            path: '',
            loadChildren: () =>
              import('../tab3/tab3.module').then(m => m.Tab3PageModule)
          },
          {
            path: 'create-saloon',
            loadChildren: () => import('../create-saloon/create-saloon.module').then(m => m.CreateSaloonPageModule)
          },
          {
            path: 'saloon-edit/:id',
            loadChildren: () => import('../tab3/saloon-edit/saloon-edit.module').then(m => m.SaloonEditPageModule)
          },
          {
            path: 'create-employee',
            loadChildren: () => import('../tab3/create-employee/create-employee.module').then(m => m.CreateEmployeePageModule)
          }
        ]
      },
      {
        path: 'tab4',
        children: [
          {
            path: '',
            loadChildren: () =>
              import('../tab4/tab4.module').then(m => m.Tab4PageModule)
          }
        ]
      },
      {
        path: 'tab5',
        children: [
          {
            path: '',
            loadChildren: () =>
              import('../tab5/tab5.module').then(m => m.Tab5PageModule)
          }
        ]
      },
      {
        path: '',
        redirectTo: '/tabs/tab1',
        pathMatch: 'full'
      }
    ]
  },
  {
    path: '',
    redirectTo: '/tabs/tab1',
    pathMatch: 'full'
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class TabsPageRoutingModule { }

Change default ion-back-buttom

Ionic Developer needed 10-20 hrs/week

$
0
0

Filmstacker Inc. is looking for an energetic part-time Ionic developer to join our startup team in bringing a collaborative video distribution platform to market.

Initial focus is Ionic-Angular Progressive Web App, then iOS with Ionic.

Check out the details, and contact us if this sounds like a fit for you!
https://filmstacker.com/careers

React IonTabs as nested route

$
0
0

Hi, I don’t speak English very well but I will try, I am searching the same problema but I not found results.

I think that you can create layout component with your tabs and pass props.children with the content page, the problem with this is that you must invoke your layout componente always you need the tabs, then all your pages have the component layout like a wrapper.

How can a python code be integrated with Ionic 4

$
0
0

This is not going to be easy.

Android apps can rely on Java being around. iOS apps can rely on Swift and/or Objective-C. That was kind of a PITA, which is why PhoneGap was born in the first place. PhoneGap apps can rely on JavaScript and a browser environment, and for stuff that needs to be closer to the metal, one has to write a plugin that again is going to have to have different implementations for Android and iOS.

So “Python” was nowhere in that last paragraph, which means there isn’t (AFAIK) a cross-platform way to write Python in mobile apps. PhoneGap turned into Cordova, which now in Ionic-land is being subsumed by Capacitor. So the first thing I would ask myself if I were you is:

Do I absolutely, positively, need this to be in Python, or can I rewrite it in TypeScript?

If there’s a chance to reimplement it in TypeScript, I would absolutely go that route, because it will be futureproof and much more lightweight to deploy and work with.

If there isn’t, you’re going to need to try to figure out how to embed a Python runtime environment and interact with it via Capacitor. Cursory Googling came across this project for Android; I have no clue whether anything remotely similar exists for iOS.


How to integrate Epson Android Sdk in Ionic for Bluetooth printing

$
0
0

Hii …
Did you find the answer?

How to use navCtrl.parent in ionic4

$
0
0

I’m migrating source code from ionic3 to ionic4.
I don’t know how to migrate using the following code.

ionic3’s code

  1. this.navCtrl.parent.parent.push(DetailPage, {selectedPage: myPage});
  2. this.navCtrl.parent.select(0);

please tell me example above code for ionic4.

How to use navCtrl.parent in ionic4

$
0
0

I’m not sure how to say this politely, especially since it’s your first post, and you should certainly feel free to hear what other people think, but I would describe this as “an opportunity to rethink the app structure, especially as it pertains to navigation”. Even with the old Ionic NavController, I have always thought it was a mistake for Ionic to expose parent, because it encourages people to spaghettify their code and blow up encapsulation.

Components should never depend on or even know anything about anything above them in the view hierarchy, because it makes them not truly independent. If the component really can’t be detached from its host, then it makes more sense to simply merge it into said host.

So as not to be completely negative, part 5 of the Tour of Heroes covers probably more than you need to know about the Angular router that you will be dealing with in v4 of the framework, and should help you as you rewrite things. One more thing: I would not pass objects like myPage through the router at all. I have had much more reliable results sticking strictly to scalars for router parameters.

Filter product by category

Unable to merge dex in ionic

$
0
0

this work’s for me.
I’m using the admob-plus for ionic

Ionic cordova build android not creating apk file

$
0
0

Hi I have the same issue for the last couple of days. It build earlier without any issues.
I have this issue when i build ionic 1 and ionic 4 app, which made me think if it is something related to my system or due to updating cordova to 9.0.0. So i tried building the apps on another system?. It works fine in the second system. So i think this is related to system heap. but i can’t figure out a way to overcome this. Any solution?

Modalcontroller resize dynamically

$
0
0

i trying to content based modal size, please help me.


Sending request as OPTIONS instead of POST,GET in backend

$
0
0

I am using Spring boot as a back end. When ever i try to hit the API using HTTP client, the requests are sending using OPTIONS instead of POST,GET. And also in front end i am getting the below CORS error.

Access to XMLHttpRequest at 'https://..........' from origin 'http://localhost:8100' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

Can anyone help me with this.

Thanks in advance.

Ionic Developer needed 10-20 hrs/week

$
0
0

Hey @j2d2,

I can help you into this as have relevant expertise.

Please check your PM,

Warm Regards,
Brianna

Ionic cordova build android not creating apk file

$
0
0

Hi sahibsingh,
after scratching my head for almost 3d, i finally found the solution.

When i tried building on the second system,my environment path for java home showed error. i corrected it at that time without looking at the version number. When i cross checked both builds, i found out that i am having an older version of jdk on my first system
The issue was caused by java. I had jdk8u231 installed on my system. Around 2 weeks ago jdk8u241 was released.I uninstalled my previous versions of jdk and jre and installed the new version and now my build works fine. My other system has automatic update turned on, so it already got the update on connecting to wifi.
I suggest you try the same. Uninstall java from control panel->programs andinstall the latest version of jdk. Make sure to correct the environment variable and restart the system before building app again

Thanks

Cordova ios plugins Failed after build complete when app loading in xcode

$
0
0

Loading XCode we are getting this error.

Any solution ?

FAILED pluginJSON = [“AuthProxy1342781311”,“AuthProxy”,“initWebStrategies”,] 2020-01-24 12:59:00.432213+0530 myJobCard[23188:330651] ERROR: Plugin ‘StatusBar’ not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 2020-01-24 12:59:00.432347+0530 myJobCard[23188:330651]
FAILED pluginJSON = [“StatusBar1342781312”,“StatusBar”,"_ready",] 2020-01-24 12:59:00.432539+0530 myJobCard[23188:330651] ERROR: Plugin ‘Console’ not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 2020-01-24 12:59:00.432642+0530 myJobCard[23188:330651]
FAILED pluginJSON = [“INVALID”,“Console”,“logLevel”,[“LOG”,“Set javascript initial log level: ERROR”]] 2020-01-24 12:59:00.432821+0530 myJobCard[23188:330651] ERROR: Plugin ‘Console’ not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 2020-01-24 12:59:00.432906+0530 myJobCard[23188:330651]
FAILED pluginJSON = [“INVALID”,“Console”,“logLevel”,[“LOG”,“Ionic Native: event fired after 444 ms”]] 2020-01-24 12:59:00.433063+0530 myJobCard[23188:330651] ERROR: Plugin ‘SMPSettingsExchangePlugin’ not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.

config.xml file
<xml version=‘1.0’ encoding=‘utf-8’?>

myJobCard
An awesome Ionic/Cordova app.
Ionic Framework Team
















































































































































We are using the following versions in npm:

List of plugins which we are using in our project:

Sending request as OPTIONS instead of POST,GET in backend

$
0
0

This is very common error.
You need to allow cross-origin request from server side. Also need to allow headers (if you are passing custom headers to HTTP request).

Viewing all 228514 articles
Browse latest View live


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