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