我的代码有问题,我在尝试使用$ http时遇到此错误。过去任何人都有这样的问题吗?
angular.js:14794 TypeError: http.get(...).than is not a function
at new <anonymous> ((index):57)
at Object.instantiate (angular.js:5112)
at angular.js:11083
at Object.link (angular-route.js:1209)
at angular.js:1383
at wa (angular.js:10611)
at q (angular.js:10000)
at f (angular.js:9240)
at angular.js:9105
at angular.js:9496 "<div ng-view="" class="ng-scope">"
这是我的代码
<body>
<nav>
<div class="nav-wrapper">
<a href="#/!" class="brand-logo right">Logo</a>
<ul class="left">
<li class="active">
<a href="#/!">CD</a>
</li>
<li>
<a href="#!dvd">DVD</a>
</li>
<li>
<a href="#!dvddl">DVD-DL</a>
</li>
</ul>
</div>
</nav>
<div ng-view></div>
<script>
var app = angular.module("diskManagment", ["ngRoute"]);
app.config(function ($routeProvider) {
$routeProvider
.when("/", {
templateUrl: "discs.htm",
controller: "cd"
})
.when("/dvd", {
templateUrl: "discs.htm",
controller: "dvd"
})
.when("/dvddl", {
templateUrl: "discs.htm",
controller: "dvddl"
});
});
app.controller("cd", ['$scope', '$http', function(scope, http) {
http.get("discs.php?type=cd")
.than(function (response) {
scope.discs = response.data.discs;
});
}]);
app.controller("dvd", ['$scope', '$http', function ($scope, $http) {
$http.get("discs.php?type=dvd")
.than(function (response) {
scope.discs = response.data.discs;
});
}]);
app.controller("dvddl", ['$scope', '$http', function ($scope, $http) {
$http.get("discs.php?type=dvddl")
.than(function (response) {
scope.discs = response.data.discs;
});
}]);
</script>
</body>
我似乎无法找出导致问题的原因,我尝试了各种方式,我发现应该有效
我真的可以使用一些帮助,谢谢!
答案 0 :(得分:0)
我写错了.than而不是.then