我想POST
數據從一個html表單到默認的動作url,但一個隱藏的輸入取決於從服務調用返回的數據。當我使用ng-submit
時,在POST
完成之前,$scope
在服務呼叫之後沒有得到更新。我無法使用Ajax POST
,因爲我在POST
之後得到了一個HTML頁面。angularjs形式行動後服務電話
的形式如下:
<form name="payment" role="form" class="form-inline" ng-show="!loading" method="POST" action="{{paymentUrl}}" ng-submit="createOrder()" novalidate>
<input type="hidden" id="responseUrl" name="responseUrl" value="{{postPaymentUrl}}"/>
<input type="hidden" id="orderNumber" name="orderNumber" value="{{orderNumber}}"/>
<select class="form-control" id="paymentMethodBrand" name="paymentMethodBrand">
<option ng-repeat="paymentMethod in paymentMethods | orderBy:'method'" value="{{paymentMethod.method}}">{{paymentMethod.method}}</option>
</select>
<button type="submit" class="btn btn-default" translate="BUY"></button>
</form>
在action
領域URL中獲取正確填寫。
控制器中createOrder
功能是這樣的:
$scope.createOrder = function() {
Payment.start($scope.selectedProduct)
.then(function (response) {
$scope.orderNumber = response.data.orderNumber;
});
};
的問題是隱藏的輸入訂單號碼沒有得到開放的實際行動網址前填補。因此發佈的數據不正確。
有關如何解決這個問題的任何想法?我使用的是angularjs 1.2.16。