2016-05-29 52 views
1

我试着在我的解决方案中使用ui-select指令。我在我的解决方案中添加了关于ui-select的整个Github文件夹。我也在app.js中注入'ui.select'。但是,当我运行的解决方案,显示在F12以下错误:ui选择错误加载“模块'ui.select'不可用!您拼错了模块名称或忘记加载它。”

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

可能是你之前angularjs文件包含它。检查。 –

回答

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页面,您无需下载文件,包括他们,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:用于ui.select

angular.module('myapp', ['ui.select', 'ngSanitize']); 

要求:

  • 角> = 1.2.18
  • ngSanitize模块
  • jQuery(对于较旧的浏览器支持可选)
  • 从Internet Explorer 8和Firefox 3.6开始的浏览器兼容性。
  • 引导/选择二/ Selectize CSS适当
+0

这是不是一个合适的解决方案更多的是解决办法的,只是工作围绕什么显然是错误地注入文件错误有太多的Angular解决方案涉及到“使用CDN”作为一种解决方案,无缘无故提升了应用程序所需的请求数 – Routhinator

+0

如何使用网络包模块? – vamsikrishnamannem

0

包括将下载的文件路径正确使用你的主index.html文件脚本标记,并确保你注入的依赖正确如下在app.js文件:

angular.module('myModule', ['ui.select']); 

(或)

另一种方法是使用包管理器:

您可以使用NPM或凉亭安装

NPM安装界面,选择

凉亭安装角度的UI选

,并确保你注入的依赖正确

angular.module('myModule', ['ui.select']); 
+0

我做了你提到的两种方式,但仍有相同的错误 – Armita

0

检查亭子文件。

如果angularjs-UI-选择不提供这一行添加到您的bower.json文件

“角UI的选择”:“〜0.18。1"

"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" 
    } 
} 
相关问题