【问题标题】:I want to update angular js varibale after ajax response我想在ajax响应后更新角度js变量
【发布时间】:2021-01-06 04:19:52
【问题描述】:
        $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 中的初始结果
****我想在发布响应值后打印 {{dis}} = 10 或 html 中的任何数字**** 我的 json 响应值为
code_id:“STIFF”

状态:“ok”

结果:“10”

【问题讨论】:

标签: php html angularjs ajax


【解决方案1】:
<span class="text-left " id="discode" >Percentage({{ ofdis = dis?dis:0}})</span> 
<input type="hidden" name="total_discount" value="{{ofdis}}">

注意:在 ng-init="myVariable='value'; "中ofdis 没有更新
只需使用 Angular js 的更新 cdn

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-20
    • 1970-01-01
    • 2021-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多