Frame Auto Submit
by Matthew Vasallo
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.3/angular.js"></script>
<div ng-controller="TestFormCtrl">
<iframe name="masteryIFrame" class="masteryIframe ng-scope" name="mastery report" title="Mastery Report" marginheight="0" marginwidth="0" allowtransparency="true" frameborder="0">
</iframe>
<form accept-charset="UTF-8" id="LTI_Launch_Form_50" name="lti_test" action="http://knewton-mindapp.awsqa.cengage.info/mindapp-adaptive-knewton/html/mastery-report" method="post" target="masteryIFrame" ng-submit="submit()">
<input type="hidden" name="isbn" value="9781305493032"/>
<input type="hidden" name="courseKey" value="MTPN3SBPQPW7"/>
<input type="hidden" name="userId" value="dc7c11040d8ef229:-6a3f0909:149aae1e921:-7516"/>
<input type="hidden" name="custom_token" value="91BDE9CC176CB34BADEC56E38FC056A3795223F67BD25031760372747C472C6C2FC7B6B326C9D71BC59B63F5FAD6BE47"/>
<input type="hidden" name="custom_courseKey" value="MTPN3SBPQPW7"/>
<input type="hidden" name="custom_eisbn" value="9781305493032"/>
</form>
</div>
JavaScript
angular.module("app", [])
.directive('form', function($timeout) {
return {
require: 'form',
restrict: 'E',
link: function(scope, element, attrs, formController) {
element[0].submit();
}
};
}).controller("TestFormCtrl", function ($scope, $element, $http) {
$scope.submit = function(){
console.log('submitted');
}
});