Hello,
Here i am introducing a way by which, you can find out the date difference in Angularjs :-
If we include the following code in controller.js file , and in that controller where we want the date difference.
So, now our controller.js look like:-
Here we are including the code in Main controller, So
Now your main.html file look like:-
Now in your html page you can see the date difference and in your console also.
Thanks
Here i am introducing a way by which, you can find out the date difference in Angularjs :-
If we include the following code in controller.js file , and in that controller where we want the date difference.
So, now our controller.js look like:-
Here we are including the code in Main controller, So
.controller('MainCtrl', function ($scope{
$scope.diffDays = [];
var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var firstDate = new Date(2015,12,31);
var secondDate = new Date(2014,10,21);
$scope.diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay)));
console.log("Remaining days in current year",$scope.diffDays)
})
Now your main.html file look like:-
<ion-view view-title=Main Page>
<ion-content class="padding">
<p>
Welcome to Angularjs
</p>
<div>
Day Difference
<b> {{diffDays}}</b>
</div>
</ion-content>
</ion-view>
Now in your html page you can see the date difference and in your console also.
Thanks
No comments:
Post a Comment