Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- (function () {
- var byallApp = angular.module('byallApp');
- byallApp.controller('ActivitieController', ['$scope', '$log', 'httpGetService', '$rootScope', 'httpPostService', '$moment',
- function ($scope, $log, httpGetService, $rootScope, httpPostService, $moment) {
- $scope.activities = [];//array that holds the objects to be displayed in table.
- ....//a lot of normal code here. No code at all that updates the $scope.activities array is ever called outside some other function.
- //function that calculates the effort, uses momentjs
- this.calculateEffortFromValues = function (finalDate, initialDate) {
- $log.info('Executing calculateEffortFromValues');
- var initial = $moment(new Date(initialDate));
- var final = $moment(new Date(finalDate));
- var duration = $moment.utc(final.diff(initial)).format("HH:mm");
- $log.info('duration: ' + duration);
- return (duration);
- }
- }]);
- })();
- <div ng-controller="ActivitiesController as activitiesCtrl">
- ....
- <tbody>
- <tr ng-repeat="activityList in activities">
- <td>{{activityList.initialDate | date : 'dd/MM/yyyy'}}</td>
- <td>{{activityList.initialDate| date : 'hh:mm a'}}</td>
- <td>{{activityList.endDate | date : 'hh:mm a'}}</td>
- **<td>{{activitiesCtrl.calculateEffortFromValues(activityList.endTime, activityList.initialTime)}}</td>**
- <td>{{activityList.codContract}}</td>
- <td>{{activityList.description}}</td>
- <td>
- <button class="btn btn-danger btn-mini" ng-click="deleteRow(row)" ng-hide="isTemp($index)"><img
- width="25px" height="25px" title="Delete Activity!" src="img/trash.ico"/></button>
- </td>
- </tr>
- </tbody>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement