Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using new AlertController inside provider (Injectable) #7221

Closed
Bouzmine opened this issue Jul 6, 2016 · 5 comments
Closed

Using new AlertController inside provider (Injectable) #7221

Bouzmine opened this issue Jul 6, 2016 · 5 comments

Comments

@Bouzmine
Copy link
Contributor

Bouzmine commented Jul 6, 2016

Short description of the problem:

I have a global Unknown error reporting service in my app which opens an alert asking the user if he wants to report the error. I used to open the alert by injecting App and then doing so :

let alert = Alert.create(...);

this.app.getActiveNav().present(alert);

When I try to inject AlertController, it triggers this error :

Cannot resolve all parameters for 'UserReport'(TranslateService, undefined). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'UserReport' is decorated with Injectable.

Where undefined is supposed to be AlertController.

What behavior are you expecting?

AlertController to properly inject.

Which Ionic Version? 2.x

Run ionic info from terminal/cmd prompt: (paste output below)
Cordova CLI: 6.1.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.10-201606302045
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
ios-deploy version: 1.8.6
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v5.0.0
Xcode version: Xcode 7.3.1 Build version 7D1014

@guillenotfound
Copy link
Contributor

I have test this with a Toast that I have when the user gets out of connection and seems to be working.

That nightly doesn't contain AlertController, LoadingController, ToastController. This where my steps (don't know if there is something better):

1 - git clone git@github.com:driftyco/ionic.git
2 - cd ionic
3 - npm install
4 - gulp build.release && gulp tests && gulp package
5 - Update your [PROJECT]/package.json to:
    "@angular/common": "^2.0.0-rc.4",
    "@angular/compiler": "^2.0.0-rc.4",
    "@angular/core": "^2.0.0-rc.4",
    "@angular/http": "^2.0.0-rc.4",
    "@angular/forms": "0.2.0",
    "@angular/platform-browser": "^2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "^2.0.0-rc.4"

6 - npm install on your project directory
7 - copy ionic/dist contents to [PROJECT]/node_modules/ionic-angular

@jgw96
Copy link
Contributor

jgw96 commented Jul 7, 2016

Hello @Bouzmine this is caused by the fact that AlertController Is now a service, and in Angular 2 a service cannot be injected into another service. I would recommend converting your error service to a component. Thanks for using Ionic! Also, @ZiFFeL1992 it seems as if your on an older nightly. You can run npm install ionic-angular@nightly to install the latest one. Thanks everyone!

@jgw96 jgw96 closed this as completed Jul 7, 2016
@jgw96 jgw96 reopened this Jul 7, 2016
@jgw96
Copy link
Contributor

jgw96 commented Jul 7, 2016

Hello all, I am going to reopen this issue as it exposed an underlying issue with AlertController and is something we want to explore more.

@guillenotfound
Copy link
Contributor

@jgw96 The latest nightly is currently I bit old, that's why I compile master.

'2.0.0-beta.10-201606302045': '2016-06-30T20:46:03.098Z'

As I said before seems like everything is working fine, but if someone else could test will be great.

@Bouzmine
Copy link
Contributor Author

Bouzmine commented Jul 7, 2016

@ZiFFeL1992 you're right, it works after following the steps above. Closing this.

@Bouzmine Bouzmine closed this as completed Jul 7, 2016
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants