在线DEMO:https://plnkr.co/edit/KAwhab7...(function(angular) { 'use strict';angular.module('scopeExample', []) .controller('MyController', ['$scope','$timeout', function($scope,$timeout) { $scope.greeting='hhh' var httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function(){ console.log(httpRequest) if(httpRequest.readyState==2){ //不更新 $scope.greeting='000' } // if(httpRequest.readyState==1){//更新 // $scope.greeting='000' // } }; httpRequest.onload = function(){ // 不更新 // $scope.greeting='333' } httpRequest.open('GET', 'https://www.json-generator.com/api/json/get/bHEfYDDHEy?indent=2'); httpRequest.send(); }]);})(window.angular);为什么angularjs只有在readyState==1会更新数据?最好可以结合源代码解释
添加回答
举报
0/150
提交
取消