asp.net mvc Angular js Datatable无法正常工作

问题描述 投票:0回答:1

我是带有数据表的角度js的新手,我在页面加载时得到,我正在尝试使用角度js添加加载数据表。

错误:

angular.js:138 Uncaught Error: [$injector:modulerr] Failed to instantiate module PMS due to:
Error: [$injector:modulerr] Failed to instantiate module angularMoment due to:
Error: [$injector:nomod] Module 'angularMoment' 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.

细节错误Error link

我的控制器

var app = angular.module('PMS', ['angularMoment', 'ui.router', 'datatables'])
    .filter('jsonDate', ['$filter', function($filter) {
        return function(input, format) {
            return (input) ? $filter('date')(parseInt(input.substr(6)), format) : '';
        };
    }]);
app.controller('SpaceController', function($scope, SpaceService) {
    $scope.getAll = function() {

        loader(true);
        var getData = SpaceService.getAllData();
        getData.then(function(response) {
            if (response.data.success) {
                $scope.listdt = response.data.data;
                $scope.populateStatus();
                loader(false);
            } else {
                errorAlert("Oops", response.data.message);
                loader(false);
            }
        });
    }
});

我的模板

@ {
    Layout = null;
} <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link href="~/Scripts/PMS_theme_js/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="~/Content/PMS_theme_css/css/style.css" rel="stylesheet">
</head>
<body ng-app="PMS" ng-controller="SpaceController">
    <table datatable="ng" class="table display" id="TblID">
        <thead>
            <tr>
                <th>ID</th>
                <th>Key</th>
                <th>Name</th>
                <th>Description</th>
                <th>Status</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="d in listdt">
                <td>{{d.SpaceID}}</td>
                <td>{{d.SpaceKey}}</td>
                <td>{{d.SpaceName}}</td>
                <td>{{d.SpaceDesc}}</td>
                <td> <span class="label label-table {{d.StatusKey == 'A' ? 'label-success' : 'label-red'}}">{{d.StatusName}}</span></td>
                <td>
                    <a class="btn btn-primary btn-sm" ng-click="edit(d)"><i class="fa fa-pencil fa-lg"></i></a>
                    <a class="btn btn-danger btn-sm" ng-click="delete(d)"><i class="fa fa-trash fa-lg"></i></a>
                </td>
            </tr>
        </tbody>
    </table>
    <script src="~/Scripts/PMS_theme_js/plugins/bower_components/jquery/dist/jquery.min.js"></script>
    <script src="~/Scripts/PMS_theme_js/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="~/Scripts/angular.js"></script>
    <script src="~/Scripts/angular-ui-router/release/angular-ui-router.min.js"></script>
    <script src="~/Scripts/datatables/media/js/jquery.dataTables.js"></script>
    <script src="~/Scripts/angular-datatables/dist/angular-datatables.js"></script>
    <script src="~/Scripts/Angular/Module.js"></script>
</body>

</html>

它与Datatable配合工作正常,但是当添加数据表模块时,它开始得到错误。任何原因在哪里以及我在使用Angular js数据表时出错了什么。

angularjs razor angular-datatables
1个回答
1
投票

您提到的错误表明您没有正确注入angularMoment,请参阅documentation

确保你在你的应用程序中包含了moment.js和angular-moment.js,在你的情况下看起来像下面的内容 -

<script src="~/Scripts/moment/moment.js"></script>
<script src="~/Scripts/angular-moment/angular-moment.js"></script>
© www.soinside.com 2019 - 2024. All rights reserved.