2014-06-07 10 views
8

Tôi đang cố gắng hiển thị trước trang AngularJS của mình bằng PhantomJS. (Với phantomjs-runner.js từ http://www.yearofmoo.com/2012/11/angularjs-and-seo.html) Tôi không thể tải trang thông qua PhantomJS như lỗi dưới đây xảy ra. Lỗi này không xảy ra trong IE/Chrome/Firefox."Không thể khởi tạo mô-đun ngSanitize" khi kết xuất trước trang AngualrJS với PhantomJS

Tôi làm cách nào để khắc phục lỗi này?

Lỗi:

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 

Mô-đun cấu hình

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); 

Trả lời

14

Dường như bạn có thể bị mất một tham chiếu đến mã ngSanitize. ngSanitize là một phần của khung AngularJS (https://docs.angularjs.org/api/ngSanitize), tuy nhiên, bạn phải bao gồm một tham chiếu riêng biệt trước khi tham chiếu PhantomJS của bạn để sử dụng nó.

Có vẻ bạn đang sử dụng phiên bản 1.2.1 của AngularJS, vì vậy bạn có thể dễ dàng chỉ cần thêm một trong các thẻ

Non-minified (hoặc lấy mã để đưa vào ứng dụng của riêng bạn.):

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-sanitize.js"></script> 

Giảm bớt:

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-sanitize.min.js"></script> 
Các vấn đề liên quan