ionic4

Ionic 4: How to focus the view of ion-segment when its clicked

牧云@^-^@ 提交于 2019-12-22 00:52:34
问题 There are five ion-segment-button, Something | Something | Something | Something | Something If I click the 4th segment the view didnt follow or focus to the current segment. Above is the current screenshot I want the view move (to the right or focus it to the center) when the segment is clicked HTML: <ion-row> <!-- ion-segment --> <ion-toolbar> <ion-segment (ionChange)="segmentChanged()" [(ngModel)]="segment" color="tertiary" scrollable> <ion-segment-button value="0"> Something </ion-segment

Ionic 4 custom components

我怕爱的太早我们不能终老 提交于 2019-12-21 03:09:31
问题 How do you load a component in ionic 4 after running the command ionic g component myComponent ? I want to add a new generated custom component to my home page. 回答1: Finally figured this out, here's a repro that works: ionic start myProject blank --type=angular ionic g module components ionic g component components/myComponent --export This adds both a declaration and export to the components module for "myComponent". To use the component just add ComponentsModule to your imports in your page

Ionic 4 - Pass Data BACK from Modal

我们两清 提交于 2019-12-20 18:34:11
问题 I'm trying to create a modal window, pass it an array of objects, have a user select one object from that array, and then have my modal pass back the object they've selected. I've tried using the Ionic 2 approach of modalName.onDidDismiss(data=> …) as explained here, but apparently Ionic 4 changed "onDidDismiss" to not accept any values passed back to it. So I'm at a loss for how to send data from my Modal window back to the page that called it. 回答1: Some days ago I had the same problem and

Close Modal in Ionic 4 by Back Button

限于喜欢 提交于 2019-12-20 17:15:52
问题 I have a Modal in Ionic 4 . I'd like to close it, when a user press the back button on her mobile (or the back button in her browser). Does anyone know how I can do this? EDIT: More details: I have a button that opens my modal: async onClick() { const modal = await this.modalController.create({ component: Foo, }); return await modal.present(); } Component Foo doesn't have much more content than a button that closes the modal: this.modalController.dismiss(); . So far so good. On my mobile,

Hiding header on content scrolling in Ionic 4

拜拜、爱过 提交于 2019-12-20 07:35:19
问题 ion-header is fixed, it stays at the top of the screen at all times. I would like it to disappear with the page as you scroll. Ive put it into ion-content which works but it has unintended side effects. Does anyone know how to create ion-header so that its not fixed to the top at all time and moved with the page ? 回答1: How about <ion-header *ngIf="hide"> While you capture the event and do this.hide = !this.hide; Tested with a button click event, and works :) Same can be changed using Simple

Ionic/Angular - Multiple routes not working

无人久伴 提交于 2019-12-20 06:15:57
问题 I have an Ionic project setup using the tabs template. Here is my issue: I have an Activity tab that will have 3 buttons on the page: Friends Near Me Global When the page first load it will show a list of post for friends, when I click on the Near Me buttons it should replace the friends post with near me posts. this works great. When I click back on Friends, it does not change the content on the page. The URL changes, but the content does not. tabs.router.module.ts: const routes: Routes = [

Not able to convert the base64 to image path in Ionic 4

妖精的绣舞 提交于 2019-12-20 03:33:17
问题 I am working on my Ionic 4 app and I have used the camera plugin for image uploading and I have converted the image to the base64 for showing the image but the problem is that I am not able to convert the base64 to proper image path for sending it to the API. This is my editimage.page.html : <ion-item class="newitem2"> <ion-avatar class="image-center"> <img name="profile_pic" [src]="this.userdetailsedit.value.profile_pic"/> <ion-icon (click)="presentActionSheet()" class="myicon11" name=

Ionic 3 geolocation not working when GPS is disabled

半城伤御伤魂 提交于 2019-12-20 02:12:31
问题 I have ionic native geolocation plugin installed "@ionic-native/geolocation": "^4.15.0" I have also tried "4.6.0" and "4.20.0". It is working absolutely fine when I keep my GPS enabled before going to that page. But when GPS is not enabled, It won't ask me to turn it ON, gives an error on console and carry undefined coordinates with it. I wrote the method of getCurrentPosition in constructor/ionViewDidLoad. So even user enable it on that page, the method does not invoke and the coordinates

Ionic 4 native plugin geolocation gives me “Module not found: Error: Can't resolve 'rxjs/Observable'”

岁酱吖の 提交于 2019-12-19 07:54:09
问题 I'm trying to use ionic native plugin geolocation in ionic 4 but I got a this error: Failed to compile. ./node_modules/@ionic-native/geolocation/index.js Module not found: Error: Can't resolve 'rxjs/Observable' in 'C:\Projects\ionic\prayers\node_modules\@ionic-native\geolocation' this is my dependencies: "dependencies": { "@angular/common": "6.0.9", "@angular/core": "6.0.9", "@angular/forms": "6.0.9", "@angular/http": "6.0.9", "@angular/platform-browser": "6.0.9", "@angular/platform-browser

Ionic 4 setRoot with Angular Router

拜拜、爱过 提交于 2019-12-18 12:22:04
问题 I'm upgrading my Ionic 3 project to the latest Ionic 4 and I have some trouble with Routing. In Ionic 3 I used setRoot just like this: handler: () => navCtrl.parent.parent.setRoot(HomePage, 'logout', {animate: true}) The latest navCtrl of Ionic 4 has only goBack, goForward and goRoot, and I don't understand how to use parent. I found ActivatedRoute in Angular, but I don't think this is the right way. How can I do? 回答1: Generally speaking, and citing this awesome article on this matter by Josh