Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. 'use strict';
  2. (function () {
  3. var byallApp = angular.module('byallApp');
  4. byallApp.controller('ActivitieController', ['$scope', '$log', 'httpGetService', '$rootScope', 'httpPostService', '$moment',
  5. function ($scope, $log, httpGetService, $rootScope, httpPostService, $moment) {
  6.  
  7. $scope.activities = [];//array that holds the objects to be displayed in table.
  8. ....//a lot of normal code here. No code at all that updates the $scope.activities array is ever called outside some other function.
  9.  
  10. //function that calculates the effort, uses momentjs
  11. this.calculateEffortFromValues = function (finalDate, initialDate) {
  12. $log.info('Executing calculateEffortFromValues');
  13. var initial = $moment(new Date(initialDate));
  14. var final = $moment(new Date(finalDate));
  15. var duration = $moment.utc(final.diff(initial)).format("HH:mm");
  16. $log.info('duration: ' + duration);
  17. return (duration);
  18. }
  19.  
  20. }]);
  21. })();
  22.  
  23. <div ng-controller="ActivitiesController as activitiesCtrl">
  24. ....
  25. <tbody>
  26. <tr ng-repeat="activityList in activities">
  27. <td>{{activityList.initialDate | date : 'dd/MM/yyyy'}}</td>
  28. <td>{{activityList.initialDate| date : 'hh:mm a'}}</td>
  29. <td>{{activityList.endDate | date : 'hh:mm a'}}</td>
  30. **<td>{{activitiesCtrl.calculateEffortFromValues(activityList.endTime, activityList.initialTime)}}</td>**
  31. <td>{{activityList.codContract}}</td>
  32. <td>{{activityList.description}}</td>
  33. <td>
  34. <button class="btn btn-danger btn-mini" ng-click="deleteRow(row)" ng-hide="isTemp($index)"><img
  35. width="25px" height="25px" title="Delete Activity!" src="img/trash.ico"/></button>
  36. </td>
  37. </tr>
  38. </tbody>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement