我尝试在我的解决方案中使用ui-select指令。我在我的解决方案中添加了关于ui-select的整个Github文件夹。我还在我的app.js中注入'ui.select'。但是当我运行解决方案时,F12中显示以下错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module MetronicApp due to:
Error: [$injector:modulerr] Failed to instantiate module oc.lazyLoad due to:
Error: [$injector:nomod] Module 'ui.select' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
答案 0 :(得分:1)
使用主index.html文件中的脚本标记正确包含下载的文件路径,并确保在app.js文件中正确注入了依赖项:
angular.module('myModule', ['ui.select']);
(或)
其他方式是使用包管理器:
您可以使用npm或bower安装
npm install ui-select
bower install angular-ui-select
并确保正确注入依赖
angular.module('myModule', ['ui.select']);
答案 1 :(得分:1)
尝试使用CDN而不是直接包含文件。
表示css:[https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.17.1/select.css]
表示js:[https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.17.1/select.js] 在主index.html页面中包含about标签,您无需下载文件并包含它们,CDN将提供文件。
HTML:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.17.1/select.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.17.1/select.js" async></script>
在app.js中:
angular.module('myapp', ['ui.select', 'ngSanitize']);
ui.select的要求:
答案 2 :(得分:0)
检查您的凉亭文件。
如果angularjs-ui-select不可用,请将此行添加到您的bower.json文件
&#34; angular-ui-select&#34;:&#34; ~0.18.1&#34;
"version": "0.0.0",
"dependencies": {
"angular-animate": "~1.5.3",
"angular-cookies": "~1.5.3",
"angular-touch": "~1.5.3",
"angular-sanitize": "~1.5.3",
"angular-messages": "~1.5.3",
"angular-aria": "~1.5.3",
"jquery": "~2.1.4",
"angular-resource": "~1.5.3",
"angular-route": "~1.5.3",
"bootstrap-sass": "~3.3.5",
"angular-bootstrap": "~0.14.3",
"malarkey": "yuanqing/malarkey#~1.3.1",
"angular-toastr": "~1.5.0",
"moment": "~2.10.6",
"animate.css": "~3.4.0",
"angular": "~1.5.3",
"angular-daterangepicker": "^0.2.2",
"angular-ui-select": "~0.18.1"
},
"devDependencies": {
"angular-mocks": "~1.5.3"
},
"overrides": {
"bootstrap-sass": {
"main": [
"assets/stylesheets/_bootstrap.scss",
"assets/fonts/bootstrap/glyphicons-halflings-regular.eot",
"assets/fonts/bootstrap/glyphicons-halflings-regular.svg",
"assets/fonts/bootstrap/glyphicons-halflings-regular.ttf",
"assets/fonts/bootstrap/glyphicons-halflings-regular.woff",
"assets/fonts/bootstrap/glyphicons-halflings-regular.woff2"
]
}
},
"resolutions": {
"jquery": "~2.1.4",
"angular": "~1.5.3"
}
}