2015-06-29 15:51:29 -07:00
|
|
|
'use strict';
|
|
|
|
|
2015-07-01 20:50:57 -07:00
|
|
|
angular.module('forms').directive('formDirective', ['$http', '$timeout', 'timeCounter', 'Auth',
|
|
|
|
function ($http, $timeout, timeCounter, Auth) {
|
2015-06-29 15:51:29 -07:00
|
|
|
return {
|
|
|
|
controller: function($scope){
|
|
|
|
timeCounter.startClock();
|
|
|
|
|
|
|
|
$scope.submit = function(){
|
|
|
|
var _timeElapsed = timeCounter.stopClock();
|
|
|
|
$scope.form.timeElapsed = _timeElapsed;
|
|
|
|
|
2015-07-01 20:50:57 -07:00
|
|
|
// console.log($scope.form.timeElapsed);
|
|
|
|
$scope.authentication = Auth;
|
|
|
|
console.log($scope.authentication.isAuthenticated());
|
2015-06-29 19:14:43 -07:00
|
|
|
|
2015-06-29 15:51:29 -07:00
|
|
|
$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;
|
2015-07-01 20:50:57 -07:00
|
|
|
})
|
|
|
|
.error(function(error){
|
|
|
|
console.log(error);
|
2015-06-29 15:51:29 -07:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.cancel = function(){
|
|
|
|
alert('Form canceled..');
|
|
|
|
};
|
|
|
|
|
|
|
|
},
|
|
|
|
templateUrl: './modules/forms/views/directiveViews/form/form.html',
|
|
|
|
restrict: 'E',
|
|
|
|
scope: {
|
|
|
|
form:'='
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]);
|