【发布时间】:2016-10-30 17:28:45
【问题描述】:
我学习了 $http 服务,但我不清楚关于 get()。下面的代码不执行 demo2.htm。请检查并告知我在哪里犯了错误。
var app = angular.module('myApp', []);
app.controller('urlCtrl', function($scope, $http) {
$http.get('demo2.htm').then(function(response) {
$scope.myWelcome = response.data;
});
});
【问题讨论】:
-
控制器是否使用过?如果它不执行,控制器可能没有加载
-
默认数据类型是 "json" 但你得到一个
.htm文件。你想用它做什么?也为这种情况添加错误处理程序 -
我想使用 $http.get() 函数查看当前文件中的另一个 HTML 文件
-
看过下面的学习网站“w3schools.com/angular/angular_http.asp”
标签: html angularjs angularjs-directive angular-http