实例化模块ngSanitize"失败;使用PhantomJS预渲染angalrjs站点时
"Failed to instantiate module ngSanitize" when pre-rendering AngualrJS site with PhantomJS
我正在尝试使用PhantomJS预渲染我的AngularJS网站。(与PhantomJS -runner.js从http://www.yearofmoo.com/2012/11/angularjs-and-seo.html)我无法通过PhantomJS加载页面,因为下面发生的错误。在IE/Chrome/Firefox中不会出现此错误。
我该如何修复这个错误?
错误:
Error: [$injector:modulerr] Failed to instantiate module SpaceForAfrica due to:
Error: [$injector:modulerr] Failed to instantiate module dialogs due to:
Error: [$injector:modulerr] Failed to instantiate module ngSanitize due to:
Error: [$injector:nomod] Module 'ngSanitize' 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.
http://errors.angularjs.org/1.2.1/$injector/nomod?p0=ngSanitize
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.js:1507
at ensure (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.js:1435)
at module (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.js:1717)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.js:3527
模块配置
var SpaceForAfrica = angular.module('SpaceForAfrica', ['ngRoute', 'HashBangURLs', 'ui.bootstrap', 'ui.bootstrap.tpls', 'google-maps', 'ui.growl', 'dialogs', 'ngSanitize', 'angularSpinner','angulartics', 'angulartics.google.analytics']).config(spaceForAfricaConfig);
看起来您可能缺少对ngSanitize代码的引用。ngSanitize是AngularJS框架的一部分(https://docs.angularjs.org/api/ngSanitize),但是,为了使用它,你必须在PhantomJS引用之前包含一个单独的引用。
看起来你正在使用AngularJS的1.2.1版本,所以你可以很容易地添加这些标签之一(或抓取代码包括在你自己的应用程序。)
Non-minified:
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-sanitize.js"></script>
缩小:
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-sanitize.min.js"></script>
相关文章:
- JavaScript滚动脚本-在测试中激发,而不是在开发站点上
- 通过iframe登录到远程站点
- Javascript移动站点重定向问题
- JQuery-在本地工作,但未定义$,仅在部署的站点上定义
- 火灾在卸载前确认警报仅适用于外部站点
- Cordova/Phonegap在主要的Cordova网络视图中加载外部站点
- 在WordPress站点中加载jquery.js后加载javascript代码
- sharepoint站点的internet explorer中出现Javascript错误
- MVC3站点脚本和CSS未加载
- API用于跨站点脚本
- Wordpress ajax使用多站点登录
- IE8/Javascript冲突?IE8正在开发中冻结整个站点-包括Javascript列表
- 移动站点重定向与完整的站点链接
- Javascript从外部站点获取html
- 当站点不是其URL的根时,如何在getJSON调用中定位API
- 使用webpack反应静态站点
- 如何使用jQuery模拟多页面站点
- Jquery无休止滚动加载来自其他站点的内容
- JavaScript:将所见即所得编辑器对实时站点的更改转换为jQuery操作
- 实例化模块ngSanitize"失败;使用PhantomJS预渲染angalrjs站点时