angularTemplatecache + gulp无法正常工作

时间:2017-05-04 15:25:31

标签: javascript angularjs gulp angular-templatecache

我正在使用 angularTemplatecache gulp 将我的所有HTML放在templates.js文件中,但我一直收到错误,似乎无法让它工作。

Uncaught ReferenceError: module is not defined

这个错误似乎源于其中包含ng-includes的模板,因为如果我从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是应用程序的根模块

0 个答案:

没有答案