Closed PatrikHorvatic closed 11 months ago
Thanks for the issue. I am going to close this as this is not a bug in Ionic Framework. The problem here is you are importing from both @ionic/angular
and @ionic/angular/standalone
. When using Angular standalone components you should not import from @ionic/angular
as noted in https://ionicframework.com/docs/angular/build-options#usage-with-standalone-based-applications.
Updating your toast import to import from @ionic/angular/standalone
should fix the issue.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Prerequisites
Ionic Framework Version
v7.x
Current Behavior
Hello.
When building the app for production, ToastController never displays toast in interface or throws any kind of error. I have created 2 videos, one displays production build and other development build.
Application is built in latest version of XCode. I am using Angular standalone components and newest Angular 17 version with Vite build system.
I have created videos for both build options, they are attached here. In login page after tapping the login button, spinner is displayed and with deliberatly false login data it dissapears and Toast should appear from top of the screen with text: "Invalid login data".
iOs development build. This build has expected behaviour and works properly.
https://github.com/ionic-team/ionic-framework/assets/80419964/d4e306ef-98a3-4d52-9e57-f7b9523450df
iOs production build This build does not have expected behaviour as toast does not appear fro mtop of the screen as seen in previous video.
https://github.com/ionic-team/ionic-framework/assets/80419964/1b6272ac-34cd-477a-be1b-3a8d5e182d9d
Expected Behavior
It is expected to display toast message in both production and development build.
Steps to Reproduce
Prepared code for the page is not equal to ones in the videos above. I have written minimal code required for bug reproduction. I have added basic button, method for event listener and basic setup of Angular NgModule based app.
1. Create InfoService InfoService contains all methods neccessery.
2. Import standalone components into AppModule
3. Create a page with NgModule
4. Add basic code to page TS code.
5. In that page add basic button with click listener.
6. Toast should appear after 500ms delay.
It is all working properly on web.
7. Build the application with following command: ionic capacitor build ios After successfull build, run the app on real device. Tapping on button should present toasts message.
8. Build the application with following command: ionic capacitor build ios --prod After successfull build, run the app on real device. Tapping on button should NOT present toasts message.
Code Reproduction URL
No response
Ionic Info
Ionic:
Ionic CLI : 7.1.1 (C:\Users\patrik.horvatic\AppData\Roaming\npm\node_modules\@ionic\cli) Ionic Framework : @ionic/angular 7.5.7 @angular-devkit/build-angular : 17.0.5 @angular-devkit/schematics : 16.2.9 @angular/cli : 17.0.5 @ionic/angular-toolkit : 10.0.0
Capacitor:
Capacitor CLI : 5.5.1 @capacitor/android : 5.5.1 @capacitor/core : 5.5.1 @capacitor/ios : 5.5.1
Utility:
cordova-res : 0.15.4 native-run : 1.7.3
System:
NodeJS : v20.9.0 (C:\Program Files\nodejs\node.exe) npm : 10.2.4 OS : Windows 10
I am also using macOs with same version of NodeJS and npm
Additional Information
Full angular.json file