我想在 ajax 响应后更新 angular js 变量
I want to update angular js varibale after ajax response
$scope.dis = 0;
$scope.getDiscount = function (value) {
$http.post('Pestcontrol/offer',{"code_id":value,}).then(function(response) {
// Stored the returned data into scope
$scope.dis = response.data.result;
console.log($scope.dis); //print 10 in console
});
};
{{dis}} = 0 html
中的初始结果
****我想在 post 响应值之后打印 {{dis}} = 10 或 html 中的任何数字 ****
我的 json 响应值是
code_id:“僵硬”
状态:“正常”
结果:“10”
<span class="text-left " id="discode" >Percentage({{ ofdis = dis?dis:0}})</span>
<input type="hidden" name="total_discount" value="{{ofdis}}">
注意:ofdis 在 ng-init="myVariable='value'; " 中没有更新
直接使用Angularjs的更新cdn
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
$scope.dis = 0;
$scope.getDiscount = function (value) {
$http.post('Pestcontrol/offer',{"code_id":value,}).then(function(response) {
// Stored the returned data into scope
$scope.dis = response.data.result;
console.log($scope.dis); //print 10 in console
});
};
{{dis}} = 0 html
中的初始结果
****我想在 post 响应值之后打印 {{dis}} = 10 或 html 中的任何数字 ****
我的 json 响应值是
code_id:“僵硬”
状态:“正常”
结果:“10”
<span class="text-left " id="discode" >Percentage({{ ofdis = dis?dis:0}})</span>
<input type="hidden" name="total_discount" value="{{ofdis}}">
注意:ofdis 在 ng-init="myVariable='value'; " 中没有更新
直接使用Angularjs的更新cdn
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>