1.在JQuery Ajax回调函数中绑定$scope实例
<div class="container" ng-app="myApp" ng-controller="myCtrl"> <div class="alert alert-danger"> 真实姓名:{{user.RealName}} <br /> {{user}} </div> </div> <script type="text/javascript"> var app = angular.module('myApp',[]); app.controller('myCtrl',function ($scope,$compile) { //使用JQuery Ajax Get请求 $.get('/ashx/dataone.ashx',{ name: '张三',text:'短内容' },function (data) { console.info(data); $scope.$apply(function () { $scope.user = JSON.parse(data); }); }); //使用JQuery Ajax Post请求 $.post('/ashx/dataone.ashx',text: '长内容' },function (data) { console.info(data); //方法1. $scope.$apply(function () { $scope.user = JSON.parse(data); }); //方法2 $scope.user = JSON.parse(data); $scope.$apply(); }); }); </script>原文链接:https://www.f2er.com/angularjs/149485.html