Closed jbarbede closed 7 years ago
Hi @jbarbede
To be honest - I didn't test the module in Ionic 2, but you could do that with the following steps:
ToastyModule
into the include
property of AppModule
class like that:import { ToastyModule } from 'ng2-toasty';
@NgModule({
declarations: [
MyApp,
// Yor components here
],
imports: [
IonicModule.forRoot(MyApp),
ToastyModule.forRoot()
],
// Other initialization properties
})
export class AppModule { }
ng2-toasty
tag into app.html
:<ion-nav [root]="rootPage" #content></ion-nav>
<ng2-toasty [position]="'center-center'"></ng2-toasty>
Copy and past the content of one of style files into app.scss
.
Inject the ToastyService
into any page:
import { Component } from '@angular/core';
import { ToastyService } from 'ng2-toasty';
@Component({
selector: 'page-feed',
templateUrl: 'feed.html',
})
export class FeedPage {
constructor(private toastyService: ToastyService) {}
showToast() {
// Just add default Toast with title only
this.toastyService.default('Hi there');
}
}
showToast
method on your page:<ion-header>
<ion-navbar>
<button ion-button icon-only menuToggle><ion-icon name="menu"></ion-icon></button>
<ion-title>Feed</ion-title>
<ion-buttons end>
<button ion-button icon-only (click)="showToast()" ><ion-icon name="walk"></ion-icon></button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content padding>
</ion-content padding>
I need some time to check what is wrong with styles and update the README with how to use ng2-toasty in Ionic 2.
hey @akserg,
Actually I integrated your plugin into our Ionic 2 app easily, without any problem. On my development machine, it works perfectly.
But we are using AOT compilation when we build the production version of our app. This is when we have a compilation error related to ng2-toasty.
Hi @jbarbede
Did you manage your problem?
Hi,
Adding that line https://github.com/cadulis/ng2-toasty/blob/master/index.ts#L10 to your index.ts makes the AOT compilation works.
Hi,
Thank you for pointing me to the issue.
Can you, please share how you integrated the ng2-toasty into Ionic 2 app? Was is similar to what I suggested above? Can you update the README and create PR to share your knowledge with other developers?
The integration like you described it in your current README is enough I guess. I followed it when I started to integrate ng2-toasty in Ionic 2 and it worked out of the box.
I'm submitting a ... [x ] bug report [ ] feature request [ ] question about the decisions made in the repository
Do you want to request a feature or report a bug? Not sure if it is a bug but I have an error when executing AOT compilation.
What is the current behavior? When I try to AOT compile my project where we included ng2-toasty, I obtain the following error:
npm ERR! Linux 3.14.32-xxxx-grs-ipv6-64 npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "ionic:build" "--prod" npm ERR! node v7.4.0 npm ERR! npm v4.0.5
export from './src/toasty.service'; export from './src/toasty.component';