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.
- Refer to this link ()
- Already follow the instruction.
- 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.
- Refer to this link (https://github./urish/angular-moment)
- Already follow the instruction.
- 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&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
afterangular.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
1 Answer
Reset to default 4You 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条)