Skip to content

Instantly share code, notes, and snippets.

@pbooth01
Created January 14, 2016 19:02
Show Gist options
  • Save pbooth01/d7f598d8f41d60cae834 to your computer and use it in GitHub Desktop.
Save pbooth01/d7f598d8f41d60cae834 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"
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.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 >
<div class="container"> </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){
$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