我正在尝试发送具有动态更改操作 url 的表单,但在更改属性后表单不会立即提交。
这是一个简单的例子: http://jsfiddle.net/THZHL/1/
<div ng-app="app">
<form name="b" action="{{url}}" methood="post" ng-controller="formCtrl">
<button type="button" ng-click="set()">1. set url</button>
<button type="submit">2. Send</button>
{{url}}
</form>
</div>
<script>
app = angular.module("app", []);
app.controller("formCtrl", function($scope){
$scope.set = function(){
$scope.url = "/abc";
}
});
</script>
我不明白为什么会这样。
最佳答案
我找到了解决方案!
$scope.url
应设置为任何非空值。就像那里:
app.controller("formCtrl", function($scope){
$scope.url = "/def";
$scope.set = function(){
$scope.url = "/abc";
}
});
关于javascript - 提交具有动态变化的 Action 属性的表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25079054/