我在注入moment.js
我的模块时遇到问题myApp
。我遵循了来自https://github.com/urish/angular-moment和https://www.npmjs.com/package/angular-momentjs但无济于事。阅读其他类似的问题和答案,很可能是由于语法不正确,但我看不到。有任何想法吗?
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular-route.min.js"></script>
<script src="scripts/moment.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="scripts/angular-moment.js"></script>
<script src="scripts/app.js"></script>
<main ng-app="myApp" ng-controller="appCtrl">
<div class="container">
<section class="ng-view">
</section>
</div>
</main>
var app = angular.module('myApp', ['ngRoute', 'angularMoment']);
app.controller('transCtrl', ['$scope', '$http', 'moment', function($scope, $http, moment){
$http.get('../json/transactions.json')
.then(function(response){
$scope.transaction = response.data.transactions;
}, function(errResponse){
alert('error');
});
$scope.sortType = 'transId'; // set the default sort type
$scope.sortReverse = false; // set the default sort order
$scope.searchTrans = ''; // set the default search/filter term
$scope.date = new moment();
console.log($scope.date)
}]);