Angular form post not working
I wrote the code below in html but I get the error "The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used."
in my html:
<form name="payment" action="{{vm.resource.authEndpoint+ '/Payment/SecondOpinionCasePayment'}}" method="post">
in the html source of the page:
<form name="payment" action="" method="post" class="ng-pristine ng-invalid ng-invalid-required">
I don't understand why the action goes black. what is the alternative for submitting the form?
The error is below angular.
Error: [$ interpolation: interr] http://errors.angularjs.org/1.3.14/ $ interpolation / interr? p0 =% 7B% 7Bvm.resource ...% 252Fapi * ****. azurewebsites.net% 252FPayment% 252FSecondOpinionCasePayment on error (native) at http: //*****.azurewebsites.net/lib.min.js: 11: 417 in K (http: // *****. azurewebsites.net/lib.min.js: 93: 52) at http: //*****.azurewebsites.net/lib.min.js: 114: 238 in the object. (Http: //*****.azurewebsites.net/lib.min.js: 112: 433) with l. $ digest (http: //*****.azurewebsites.net/lib.min.js: 128: 3) with l. $ apply (http: //*****.azurewebsites.net/lib.min.js: 131: 58) at l (http: //*****.azurewebsites.net/lib.min.js: 86: 171) to S (http: //*****.azurewebsites.net/lib.min.js: 90: 301) to XMLHttpRequest.D.onload (http: //*****.azurewebsites. net / lib.min.js: 91: 315)
source to share
Create a url in your controller, wrap it and $sce.trustAsResourceUrl()
use it $sce
to sanitize items from potentially unsafe content, as long as you trust the url you can use $sce
.
Embed 'ngSanitize'
in your application,
var app = angular.module('myApp', ['ngSanitize']);
then the controller will,
app.controller('urlController',['$scope', '$sce', function($scope, $sce){
var actionURL = vm.resource.authEndpoint+"/Payment/SecondOpinionCasePayment";
$scope.formAction = $sce.trustAsResourceUrl(actionURL);
}]);
then in html form,
<form name="payment" action="{{formAction}}" method="post">
source to share