javascript - Uncaught ReferenceError: angular is not defined at angular-moment.js - Stack Overflow

I've been sitting with this problem about an hour, I'm not sure what went wrong. I've be

I've been sitting with this problem about an hour, I'm not sure what went wrong. I've been looking this question at stackoverflow, but nothing can help me. I tried to putting Moment js in my project.

  1. Refer to this link ()
  2. Already follow the instruction.
  3. Got error: angular is not defined at angular-moment.js:630.

This is my code:

index.html

<!-- moment extension -->
    <script src="lib/moment/moment.js"></script>
    <script src="lib/angular-moment/angular-moment.js"></script>

    <!-- ionic/angularjs js -->
    <script src=";amp;sensor=false"></script>
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="cordova.js"></script>
    <script src="lib/ionic-timepicker/dist/ionic-timepicker.bundle.min.js"></script>
    <script src="lib/ngCordova/dist/ng-cordova.min.js"></script>

Javascript

angular.module('starter.controller', ['ionic', 'ionic-timepicker', 'angularMoment'])
.controller('checkoutOrderCtrl', function ($scope, moment) {
        var NowMoment = moment();
        $rootScope.date = NowMoment.format('YYYY-MM-DD');
        $rootScope.time = NowMoment.format('h:mm:ss');
}

Thanks for help.

I've been sitting with this problem about an hour, I'm not sure what went wrong. I've been looking this question at stackoverflow, but nothing can help me. I tried to putting Moment js in my project.

  1. Refer to this link (https://github./urish/angular-moment)
  2. Already follow the instruction.
  3. Got error: angular is not defined at angular-moment.js:630.

This is my code:

index.html

<!-- moment extension -->
    <script src="lib/moment/moment.js"></script>
    <script src="lib/angular-moment/angular-moment.js"></script>

    <!-- ionic/angularjs js -->
    <script src="http://maps.googleapis./maps/api/js?libraries=places&amp;sensor=false"></script>
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="cordova.js"></script>
    <script src="lib/ionic-timepicker/dist/ionic-timepicker.bundle.min.js"></script>
    <script src="lib/ngCordova/dist/ng-cordova.min.js"></script>

Javascript

angular.module('starter.controller', ['ionic', 'ionic-timepicker', 'angularMoment'])
.controller('checkoutOrderCtrl', function ($scope, moment) {
        var NowMoment = moment();
        $rootScope.date = NowMoment.format('YYYY-MM-DD');
        $rootScope.time = NowMoment.format('h:mm:ss');
}

Thanks for help.

Share asked Dec 8, 2015 at 7:49 Siti Aishah IsmailSiti Aishah Ismail 6591 gold badge13 silver badges32 bronze badges 4
  • I hope this is not a stupid question. But you din´t load angular.js anywhere, did you? – David P. Commented Dec 8, 2015 at 7:52
  • You should put your angular.moment.js after angular.js script tag. – Tyler.z.yang Commented Dec 8, 2015 at 7:53
  • Where is the Angular JS file? Then you need to put angular-moment after that. – michelem Commented Dec 8, 2015 at 7:55
  • Oh I see, actually I already add "angular.js" after "angular.moment.js" before this. But got same error, so now everything already fixed by putting "angular.js" before "angular.moment.js" and after that it give me warning "WARNING: Tried to load angular more than once." – Siti Aishah Ismail Commented Dec 8, 2015 at 8:10
Add a ment  | 

1 Answer 1

Reset to default 4

You need to place angular-moment.js after angular.js file:

<script src="angular.min.js"></script>
<!-- moment extension -->
<script src="lib/moment/moment.js"></script>
<script src="lib/angular-moment/angular-moment.js"></script>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744862407a4597779.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信