Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://stackoverflow.com/questions/16003188/can-i-trigger-a-form-submit-from-a-controller
- <form ng-form-commit action="/" name='payForm' method="post" target="_top">
- <input type="hidden" name="currency_code" value="USD">
- <button type='button' ng-click='save(payForm)'>buy</button>
- </form>
- .directive("ngFormCommit", [function(){
- return {
- require:"form",
- link: function($scope, $el, $attr, $form) {
- $form.commit = function() {
- $el[0].submit();
- };
- }
- };
- }])
- .controller("AwesomeCtrl", ["$scope", function($scope){
- $scope.save = function($form) {
- if ($form.$valid) {
- $form.commit();
- }
- };
- }])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement