我使用ngPrint时遇到错误

时间:2016-02-09 04:07:23

标签: angularjs gulp

我开发了gulp应用程序。有我使用ngPrint打印表。

这是模块包含,

var myapp = angular.module('myapp', ['ngPrint']);

和像这样的HTML代码,

<h1 id="printThisElement">Hello Bro!</h1>
<button class="btn btn-primary" ng-print print-element-id="printThisElement">

我用这个开发example

低于我的错误,

Uncaught Error: [$injector:modulerr] Failed to instantiate module lgps due to:
Error: [$injector:modulerr] Failed to instantiate module ngPrint due to:
Error: [$injector:nomod] Module 'ngPrint' 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.4.8/$injector/nomod?p0=ngPrint
at http://localhost:8000/vendor/angular.js:68:12
at http://localhost:8000/vendor/angular.js:2005:17
at ensure (http://localhost:8000/vendor/angular.js:1929:38)
at module (http://localhost:8000/vendor/angular.js:2003:14)
at http://localhost:8000/vendor/angular.js:4435:22
at forEach (http://localhost:8000/vendor/angular.js:340:20)
at loadModules (http://localhost:8000/vendor/angular.js:4419:5)
at http://localhost:8000/vendor/angular.js:4436:40
at forEach (http://localhost:8000/vendor/angular.js:340:20)
at loadModules (http://localhost:8000/vendor/angular.js:4419:5)
http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=ngPrint&p1=Error%3A…dModules%20(http%3A%2F%2Flocalhost%3A8000%2Fvendor%2Fangular.js%3A4419%3A5)
at http://localhost:8000/vendor/angular.js:68:12
at http://localhost:8000/vendor/angular.js:4458:15
at forEach (http://localhost:8000/vendor/angular.js:340:20)
at loadModules (http://localhost:8000/vendor/angular.js:4419:5)
at http://localhost:8000/vendor/angular.js:4436:40
at forEach (http://localhost:8000/vendor/angular.js:340:20)
at loadModules (http://localhost:8000/vendor/angular.js:4419:5)
at createInjector (http://localhost:8000/vendor/angular.js:4344:11)
at doBootstrap (http://localhost:8000/vendor/angular.js:1676:20)
at bootstrap (http://localhost:8000/vendor/angular.js:1697:12)
http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=lgps&p1=Error%3A%20…otstrap%20(http%3A%2F%2Flocalhost%3A8000%2Fvendor%2Fangular.js%3A1697%3A12)

我如何解决这个问题我尝试了很多方法,但我无法得到结果。

1 个答案:

答案 0 :(得分:1)

该错误表明角度无法找到ngPrint模块。您是否包含了所需的js文件?

 <link rel="stylesheet" href="https://cdn.rawgit.com/gilf/ngPrint/master/ngPrint.min.css" />
    <script src="https://rawgit.com/gilf/ngPrint/master/ngPrint.min.js"></script>

干杯