0

我正在使用带有 gulpangularTemplatecache将我的所有 HTML 放入一个 templates.js 文件中,但我不断收到错误并且似乎无法让它工作。

Uncaught ReferenceError: module is not defined

此错误似乎源于其中包含 ng-include 的模板,因为如果我从 templates.js 文件中删除它们并正常加载它们,它就可以工作。这是一个给我带来问题的模板

<div class="box-flight-search" ng-show="showNewFlightSearch">
    <flight-search-options fn-flight-search="onFlightSearch"
                           city-airport-data="citiesAndAirportsData"
                           airv-data="airvsData"
                           ptc-data="ptcData"
                           fare-class-data="fareClassData"></flight-search-options>
</div>
&nbsp;
<div class="box-flight-search" ng-show="showLastPnr && showNewFlightSearch">
    <ng-include src="'app/dashboard/views/dashboard.last.pnrs.html'" />
</div>

<div class="container-fluid" ng-if="!showNewFlightSearch">
    <div class="row">
        <!-- ng-hide="showNewFlightSearch" -->
        <div class="main-search-wrapper">
            <div class="inner animated">
                <uib-tabset active="0">
                    <uib-tab index="0">
                        <uib-tab-heading class="lead">
                            <i class="glyphicon glyphicon-plane"></i>&nbsp; {{::resource.fields.Fields.FLIGHT_SEARCH}}
                        </uib-tab-heading>
                        <br />
                        <ng-include src="getTemplate('flightSearch')"></ng-include>
                    </uib-tab>
                </uib-tabset>
            </div>
        </div>
    </div>
    <div class="row" ng-show="viewLastPnr">
        <ng-include src="'app/dashboard/views/dashboard.last.pnrs.html'"
                    ng-controller="DashboardLastPnrController"
                    ng-init="onInit(false)" />
    </div>
</div>

getTemplate 函数我是这样的

$scope.getTemplate = function (template) {
    switch (template) {
        case "flightSearch":
            return $scope.viewsPath + "views/dashboard.search_NXG.html";
        case "lastPnr":
            return $scope.viewsPath + "views/dashboard.last.pnrs.html";
        case "queues":
            return $scope.viewsQueues + "views/queues.component.html";
    }
};

关于如何解决这个问题的任何想法?

编辑:这是我的 template.js。该文件有更多,但为了简单起见我只是删除了

angular.module("AppRoot").run(["$templateCache",function($templateCache){
$templateCache.put("footer.html",'html here'),
$templateCache.put("app/dashboard/views/dashboard.last.pnrs.html",'html here),
$templateCache.put("app/dashboard/views/dashboard.retrieve.reservation.html",'html here')}]);

AppRoot 是应用程序的根模块

4

0 回答 0