简体   繁体   中英

How to inject this dependency in angularjs?

I am having diffculty injecting this dependency: https://cdnjs.cloudflare.com/ajax/libs/angularjs-dropdown-multiselect/2.0.0-beta.10/src/angularjs-dropdown-multiselect.js into my project.

Here is the dependency injection scheme used in the project:

  angular.module("myModule").controller("myController", MyController); function MyController($scope, $window, angular-js-dropdown-multiselect ){ } MyController.$inject = ["$scope", "$window", "angular-js-dropdown-multiselect"] 

However angular throws a Error: $injector:unpr Unknown Provider error.

I've tried changing angular-js-dropdown-multiselect to angularJsDropdownMultiselect but still see the error.

Any suggestions?

Thanks, Matt

You're trying to inject a module as opposed to a provider. Include that script on your page and inject whatever providers that module exposes.

Looking at that file, it doesn't expose anything but a directive, so just do something like the following:

JS:

angular.module('yourMoudule', ['angularjs-dropdown-multiselect'])

Usage:

<div dm-dropdown-static-include>...</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM