如何使用angularjs包含脚本

时间:2022-12-06 09:25:47

I used yeoman to generate an angularjs project. I want to use ng-breadcrumbs so I installed it and when I try to add angular.module('ab', ['ngRoute', 'ng-breadcrumbs']) I have an error Failed to instantiate module ng-breadcrumbs due to: [$injector:nomod] Module 'ng-breadcrumbs' is not available! You either misspelled the module name or forgot to load it. I guess I have to load the js file but where ? I don't understand where yeoman do that ? I can't find any loaded file . Shall I just do it in root.html ? or index.html ? Other question, I am suing angular ui router, it works with ng-breadcrumbs too or I have to use ngRoute ? I can't find script src="angular.js" in any file

我使用约曼来生成一个angularjs项目。我想要使用ng-breadcrumb,所以我安装了它,当我尝试添加角的时候。模块('ab', ['ngRoute', 'ng-面包屑'])我有一个错误,没有实例化模块ng-面包屑,因为:[$injector:nomod]模块'ng-面包屑'是不可用的!您要么拼错了模块名,要么忘记加载它。我想我必须加载js文件,但是在哪里呢?我不明白约曼是怎么做到的?我找不到任何已加载的文件。我用根结点来做吧。html ?或索引。html ?还有问题,我用的是角ui路由器,它也可以用ng-breadcrumb,还是用ngRoute ?我找不到脚本src="角度"。js”在任何文件

2 个解决方案

#1


2  

Include ng-breadcrumbs.min.js after including angular.min.js in your index.html.

包括ng-breadcrumbs.min。js后包括angular.min。js在您的index . html。

If you are planning to use ngRoute, you have to include angular-route.js. Dependency injection would be angular.module('yourApp', ['ngRoute']);

如果您打算使用ngRoute,则必须包含angular-route.js。依赖注入是有角的。模块(“yourApp”,[' ngRoute ']);

If you are using UI Router, you have to include angular-ui-router.min.js. Dependency injection would be angular.module('yourApp', ['ui.router']);

如果您正在使用UI路由器,您必须包含angular-ui-router.min.js。依赖注入是有角的。模块(“yourApp”,[' ui.router ']);

ng-breadcrumbs could be used with ng-route as presented here

ng-面包屑可以用在这里的ng路线。

#2


0  

In index.html right after script src="angular.js" you have to add ng-breadcrumbs javascript source.

在索引。在脚本src="有棱角的。你必须添加ng-面包屑javascript源代码。

You can install it via

您可以通过

bower install ng-breadcrumbs --save

then add to index.html

然后添加到index . html

<script src="bower_components/ng-breadcrumbs/dist/ng-breadcrumbs.min.js">

#1


2  

Include ng-breadcrumbs.min.js after including angular.min.js in your index.html.

包括ng-breadcrumbs.min。js后包括angular.min。js在您的index . html。

If you are planning to use ngRoute, you have to include angular-route.js. Dependency injection would be angular.module('yourApp', ['ngRoute']);

如果您打算使用ngRoute,则必须包含angular-route.js。依赖注入是有角的。模块(“yourApp”,[' ngRoute ']);

If you are using UI Router, you have to include angular-ui-router.min.js. Dependency injection would be angular.module('yourApp', ['ui.router']);

如果您正在使用UI路由器,您必须包含angular-ui-router.min.js。依赖注入是有角的。模块(“yourApp”,[' ui.router ']);

ng-breadcrumbs could be used with ng-route as presented here

ng-面包屑可以用在这里的ng路线。

#2


0  

In index.html right after script src="angular.js" you have to add ng-breadcrumbs javascript source.

在索引。在脚本src="有棱角的。你必须添加ng-面包屑javascript源代码。

You can install it via

您可以通过

bower install ng-breadcrumbs --save

then add to index.html

然后添加到index . html

<script src="bower_components/ng-breadcrumbs/dist/ng-breadcrumbs.min.js">