$http 服务, 是 AngularJS 中的一个核心服务,用于读取远程服务器的数据。 服务向服务器发送请求,应用响应服务器传送过来的数据。
app.controller('myCtrl', function($scope, $http) {
$http.get("welcome.htm").then(function (response) {
$scope.myWelcome = response.data;
});
});
app.controller('myCtrl', function($scope, $http) {
$http.get("welcome.htm").then(function (response) {
$scope.myWelcome = response.data;
});
});
本文介绍AngularJS中$http服务的应用实例,通过控制器调用$http.get方法从服务器加载welcome.htm文件,并将返回的内容赋值给$scope.myWelcome变量。
7669

被折叠的 条评论
为什么被折叠?



