【问题标题】:angular form action post not working角形动作柱不起作用
【发布时间】:2015-09-14 13:35:24
【问题描述】:

我在 html 中编写了以下代码,但收到错误“您正在查找的页面无法显示,因为正在使用无效的方法(HTTP 动词)。”

在我的 html 中:

<form name="payment" action="{{vm.resource.authEndpoint+ '/Payment/SecondOpinionCasePayment'}}" method="post">

在html页面源码中:

<form name="payment" action="" method="post" class="ng-pristine ng-invalid ng-invalid-required">

我并没有低估为什么行动会变黑。表单帖子的替代方法是什么?

低于角度误差。

错误:[$interpolate:interr] http://errors.angularjs.org/1.3.14/$interpolate/interr?p0=%7B%7Bvm.resource...%252Fapi*****.azurewebsites.net%252FPayment%252FSSecondOpinionCasePayment 在错误(本机) 在 http://*****.azurewebsites.net/lib.min.js:11:417 在 K (http://*****.azurewebsites.net/lib.min.js:93:52) 在 http://*****.azurewebsites.net/lib.min.js:114:238 在对象。 (http://*****.azurewebsites.net/lib.min.js:112:433) 在 l.$digest (http://*****.azurewebsites.net/lib.min.js:128:3) 在 l.$apply (http://*****.azurewebsites.net/lib.min.js:131:58) 在 l (http://*****.azurewebsites.net/lib.min.js:86:171) 在 S (http://*****.azurewebsites.net/lib.min.js:90:301) 在 XMLHttpRequest.D.onload (http://*****.azurewebsites.net/lib.min.js:91:315)

【问题讨论】:

    标签: angularjs html forms


    【解决方案1】:

    您可能在范围内拥有的是基本 url 的模型。 修改为:

    <form name="payment" action="{{vm.resource.authEndpoint}}/Payment/SecondOpinionCasePayment" method="post">
    

    【讨论】:

    • 我已根据您的评论更新了代码,但无法正常工作
    • 没有足够的信息来帮助你进一步,错误似乎在vm.Resource中,分享角度代码。
    • in html
      in .js var vm = this;跨度>
    • 我也厌倦了在 div 中打印和工作,但它在表单中不起作用
      {{vm.resource.authEndpoint+'/Payment/SecondOpinionCasePayment'}}
    【解决方案2】:

    在你的控制器中形成 URL,用$sce.trustAsResourceUrl() 包裹它 使用 $sce 从潜在的不安全内容中清除元素,如果您信任该 URL,则可以使用 $sce。

    在您的应用中注入'ngSanitize',

    var app = angular.module('myApp', ['ngSanitize']);
    

    那么控制器就是,

    app.controller('urlController',['$scope', '$sce', function($scope, $sce){
    
    var actionURL = vm.resource.authEndpoint+"/Payment/SecondOpinionCasePayment";
    
        $scope.formAction = $sce.trustAsResourceUrl(actionURL);
    
    }]);
    

    然后在你的html表单中,

    <form name="payment" action="{{formAction}}" method="post">
    

    【讨论】:

      猜你喜欢
      相关资源
      最近更新 更多
      热门标签