Unknown provider: ngTagsInputProvider <- ngTagsInput

I injected version 2.1.1 of ngtagsinput like this into my controller:

app.controller('homeCtrl', ['$scope','$http','ngTagsInput', function($scope,$http){
}])

      

* NOTE: TEST! add ngTagsInput to function () won't matter ...

I downloaded the ngtagsinput lib after the angularjs lib.

I wonder what else I could check to solve this very simple but screwed up error:

Error: [$injector:unpr] Unknown provider: ngTagsInputProvider <- ngTagsInput
http://errors.angularjs.org/1.2.9/$injector/unpr?p0=ngTagsInputProvider%20%3C-%20ngTagsInput

      

Don't get me wrong. I know this provider was not found.

but my library was found (did not report 404), I saw that ngTagsInput is used in its library ....

So its really eavesdropping on me the same solution no longer works for this library! What is special about this lib and why does this bug exist when I met the whole standard to fix it?

Thanks for the help Plz!

+3


source share


1 answer


It looks like you were trying to inject ngTagsInput

into your controller, while you have to inject into your module as a dependency. For example:

angular.module('myApp', ['ngTagsInput'])

      

a block of notes, not a controller

You can see according to the creators example: https://github.com/mbenford/ngTagsInput#example




This is because there are several types of injection used in angular. When you declare a module, you need to specify what other modules are available for use in your module.

See: https://docs.angularjs.org/guide/module

When you type into a controller, you are basically saying that you want to use a specific object in it. This object must be part of your module for it to be valid. For a third party library, this usually means adding it as a module dependency (as mentioned above) and then injecting any object that is part of that library into your controllers and services.

+7


source







All Articles