0

嗨,我有一个使用 Grunt bower 和 yeoman 创建的 AngularJS 应用程序。

我正在尝试在应用程序上执行grunt serve:dist。虽然缩小一些 HTML 会显示错误并且即使我这样做也不会缩小--force

我的视图中有一些 HTML 页面。

应用程序.html

<!-- build:js scripts/applicationctrl.js -->
<script src="scripts/controllers/appln.js"></script>
<!-- endbuild -->
<div ng-if="view" id="application"
    class="tab-pane active">

    <div class="box-header blue-background">
        <div class="title">
            <div class="icon-edit"></div>
            Application Information
        </div>
    </div>

    <form class="form form-horizontal " id="appForm" name="appForm"
        ng-submit="saveapplication()" ng-if="update"
        style="margin-top: 1%">
        <div ng-if="statusMessage!=null"
            class="alert {{alertType}} alert-dismissable">
            <a class="close" data-dismiss="alert" href="">× </a> <i
                class="{{statusIcon}}"></i> {{statusMessage}}
        </div>
        <div class="groupedColumns"
            ng-if="allowed">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="control-label col-sm-4 " for="applicationName">Application
                        : <span class="required">*</span>
                    </label>
                    <div class="col-xs-7 controls">
                        <input class="form-control input-sm inline-block"
                            data-rule-required="true" ng-model="application.name"
                            placeholder="Application Name" required="required" />
                    </div>
                    <div class="availability-result">
                        <i id="loading" class="{{spinnerClass}}"></i> <span
                            class="{{msgClass}}"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4 " for="applicationID">Application
                        ID : </label>
                    <div class="col-xs-7 controls">
                        <input class="form-control input-sm"
                            ng-model="application.applicationId" id="applicationID"
                            name="applicationID" placeholder="Application ID" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

我在同一个视图文件夹中有另一个文件。

信息.html

<!-- build:js scripts/infoctrl.js -->
<script src="scripts/controllers/info.js"></script>
<!-- endbuild -->
<div class="box bordered-box" ng-if="tabpage.enable">
    <div class="box-content box-no-padding">
        <div class="responsive-table">
            <div class="box-header">
                <div class="title icon-truck">Summary</div>
            </div>
            <div class="form-group col-sm-6 no-margin-bottom">
                <label
                    class="control-label col-sm-5 col-xs-12 input-sm-attr no-padding">Active
                    : </label>
                <div>
                    <input class"no-padding" type="checkbox" ng-model="info.isActive"
                        ng-change="enablesave()">
                </div>
            </div>
            <div class="col-xs-2 actions">
                <button type="submit" id="infoSaveID"
                    ng-disabled="savebutton.enable" value="Save"
                    ng-click="saveInfo()"
                    class="btn btn-primary icon-ok icon-white">Save</button>
            </div>
            <div class="scrollable-area" style="padding-top: 5px;">
                <table class="table-condensed table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th class="col-size-reduce"
                                ng-repeat="(key ,value) in infoStatus[0]">{{key}}</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in infoStatus">
                            <td class="col-size-reduce" ng-repeat="(key, value) in row">
                                {{value}}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

我也有很多这样的文件。

当我执行 grunt serve:dist 时,它会缩小第一个 html 页面。虽然它在缩小 info.html 页面时显示错误

Warning: dist/views/info.html
Parse Error: <input class"no-padding" type="checkbox" ng-model="info.isActive"
                        ng-change="enablesave()">
                </div>
            </div>
            <div class="col-xs-2 actions">
                <button type="submit" id="infoSaveID"
                    ng-disabled="savebutton.enable" value="Save"
                    ng-click="saveInfo()"
                    class="btn btn-primary icon-ok icon-white">Save</button>
            </div>
            <div class="scrollable-area" style="padding-top: 5px;">
                <table class="table-condensed table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th class="col-size-reduce"
                                ng-repeat="(key ,value) in infoStatus[0]">{{key}}</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in infoStatus">
                            <td class="col-size-reduce" ng-repeat="(key, value) in row">
                                {{value}}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div> Used --force, continuing.
Warning: Cannot read property 'length' of undefined Used --force, continuing.

为什么第一个工作正常,第二个显示错误?如何解决?

4

1 回答 1

0

您的 HTML 语法有错误。在第一行,替换

<input class"no-padding" type="checkbox" ng-model="info.isActive"
                        ng-change="enablesave()">

经过

<input class="no-padding" type="checkbox" ng-model="info.isActive"
                        ng-change="enablesave()">

并且 htmlmin 将正常工作。

于 2014-12-01T01:03:12.707 回答