Posts tagged Ionic

Angular2/Ionic2: No provider for ….

When your developing an angular 2/ionic 2 application and you get the the following error:

EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error in :0:0
ORIGINAL EXCEPTION: No provider for UserService!
ORIGINAL STACKTRACE:
Error: DI Exception
    at NoProviderError.BaseException [as constructor] (http://localhost:8100/build/js/app.bundle.js:2300:23)
    at NoProviderError.AbstractProviderError [as constructor] (http://localhost:8100/build/js/app.bundle.js:27491:16)
    at new NoProviderError (http://localhost:8100/build/js/app.bundle.js:27528:16)
    at ReflectiveInjector_._throwOrNull (http://localhost:8100/build/js/app.bundle.js:28516:19)
    at ReflectiveInjector_._getByKeyDefault (http://localhost:8100/build/js/app.bundle.js:28544:25)
    at ReflectiveInjector_._getByKey (http://localhost:8100/build/js/app.bundle.js:28507:25)
    at ReflectiveInjector_.get (http://localhost:8100/build/js/app.bundle.js:28316:21)
    at ElementInjector.get (http://localhost:8100/build/js/app.bundle.js:29890:48)
    at ElementInjector.get (http://localhost:8100/build/js/app.bundle.js:29890:48)
    at ReflectiveInjector_._getByKeyDefault (http://localhost:8100/build/js/app.bundle.js:28541:24)
ERROR CONTEXT:
[object Object]

Your module exists, it’s setup and your import is working. So what’s up? You need to make it available for your application. In your app.ts you have 2 approach’s add a new paramter to your @Component called providers that takes an array of modules.

Angular 2 (non-Ionic)

@Component({ 
  templateUrl: “build/app.html”,
  providers: [UserService],
})

For Ionic you can also just pass it into the ionicBootstrap function, the second parameter to that is an array of modules:

ionicBootstrap(ConnectApp, [UserService]);

Hope this helps!

Ionic\Cordova EACCESS Error

ionic-logo-blogWhen your running the command “ionic run ios or ionic emulate ios” on a Mac you may be presented with the following error:

Error: spawn EACCES

The most common cause of this error is that the scripts in your hooks directory don’t have execute permission. You may also try removing and adding your ios provider. If that doesn’t work the other fix is to run the following command:

sudo find /path/to/your/app/hooks -type f -exec chmod +x {} \;

This will iterate over every file in your hooks directory and grant execute permission. Try running the run/emulate command again and the problem should be gone.

If you’re a First Responder or know one check out Resgrid which is a SaaS product utilizing Microsoft Azure, providing logistics, management and communication tools to first responder organizations like volunteer fire departments, career fire departments, EMS, search and rescue, CERT, public safety, disaster relief organizations.

VSCode and Ionic/Cordova Platform File Locking

If your running into file locking, like in the platform/android/assets/www folder, trying to use the Ionic or Cordova CLI tools with VSCode you need to exclude those folders from your VSCode’s explorer. The benefit here is also they will disappear from your search results from VSCode as well.

The error you might be receiving might look like:

rm: could not remove directory (code ENOTEMPTY): pathto\platforms\android\assets\www/js/libs

In Windows select File->Preferences->Workspace Settings.

2016-06-24 21_02_16-settings.json - Responder - Visual Studio Code

A split screen editor will appear, edit the right hand window, it may be almost blank and include the files.exclude object from below.

// Place your settings in this file to overwrite default and user settings.
{
“files.exclude”: {
“**/.git”: true,
“**/.DS_Store”: true,
“**/node_modules”: true,
“node_modules”: true,
“platforms”: true,
“plugins”: true
}

}

Once you save the settings.json file they should disappear from your VSCode explorer, but you may need to restart VSCode to make sure.

Go to Top