Skip to content

Instantly share code, notes, and snippets.

@adatta02
Forked from pbooth01/auto submit form example
Created January 14, 2016 19:06
Show Gist options
  • Save adatta02/e4221b7597d55e7e95bc to your computer and use it in GitHub Desktop.
Save adatta02/e4221b7597d55e7e95bc to your computer and use it in GitHub Desktop.
auto submit form example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Angular Demo</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="demostyles.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min.js"></script>
</head>
<body ng-app='angularDemoApp'>
<div class="container" ng-controller="DemoCtrl">
</div>
<script>
angular.module('angularDemoApp', [])
.directive('autoSubmitForm', function($timeout){
return {
restrict: 'E',
replace: true,
scope: {name: '=', age: "="},
templateUrl: 'partials/hiddenForm.html',
link: function(scope, el, attr){
$timeout(function() {
angular.element(el).submit();
});
}
};
})
.controller('DemoCtrl', function ($scope){
alert("hi!");
$scope["utilizeInfo"] = function(){
$scope["submitForm"] = {name: "Phil", age: "23"};
}
})
;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment