36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
angular.module('forms').directive('formDirective', ['$http', '$timeout', 'timeCounter',
|
||
|
function ($http, $timeout, timeCounter) {
|
||
|
return {
|
||
|
controller: function($scope){
|
||
|
timeCounter.startClock();
|
||
|
|
||
|
|
||
|
$scope.submit = function(){
|
||
|
var _timeElapsed = timeCounter.stopClock();
|
||
|
$scope.form.timeElapsed = _timeElapsed;
|
||
|
|
||
|
console.log($scope.form.timeElapsed);
|
||
|
|
||
|
$http.post('/forms/'+$scope.form._id,$scope.form).
|
||
|
success(function(data, status, headers){
|
||
|
console.log('form submitted successfully');
|
||
|
alert('Form submitted..');
|
||
|
$scope.form.submitted = true;
|
||
|
});
|
||
|
};
|
||
|
|
||
|
$scope.cancel = function(){
|
||
|
alert('Form canceled..');
|
||
|
};
|
||
|
|
||
|
},
|
||
|
templateUrl: './modules/forms/views/directiveViews/form/form.html',
|
||
|
restrict: 'E',
|
||
|
scope: {
|
||
|
form:'='
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
]);
|