AngularJS一直告诉我我的控制器不是一个函数
在浏览器中运行应用程序时,控制台会告诉我: 错误:[ng:areq]参数“FlightListController”不是函数,未定义 “FlightListController”通过“ng视图”绑定到my index.html 现在我不知道角度误差想告诉我什么。隐藏在错误背后的错误并没有真正的帮助AngularJS一直告诉我我的控制器不是一个函数,angularjs,Angularjs,在浏览器中运行应用程序时,控制台会告诉我: 错误:[ng:areq]参数“FlightListController”不是函数,未定义 “FlightListController”通过“ng视图”绑定到my index.html 现在我不知道角度误差想告诉我什么。隐藏在错误背后的错误并没有真正的帮助 var app = angular.module("flightlog"); app.controller("FlightListController", ['$scope', '$http', f
var app = angular.module("flightlog");
app.controller("FlightListController", ['$scope', '$http', function ($scope, $http) {
$http.get("http://localhost:3000/flights").success(function (response) {
$scope.flights = response;
}).error(function (err) {
$scope.error = err;
});
}]);
HTML:
如果我没说错,您是在告诉视图,该视图是他的控制器,您应该使用: ng控制器不是ng视图
<div class="container" ng-controller="FlightListController">
-文档您的控制器不是名为“Flight”吗,不是“FlightListController”。。。经过几个小时的编码后,我总是对拼写错误视而不见。谢谢
var app = angular.module("flightlog");
app.controller("Flight", function ($scope, $http) {
$http.get("http://localhost:3000/flights").success(function (response) {
$scope.flights = response;
}).error(function (err) {
$scope.error = err;
});
var app = angular.module("flightlog");
app.controller("FlightListController", ['$scope', '$http', function ($scope, $http) {
$http.get("http://localhost:3000/flights").success(function (response) {
$scope.flights = response;
}).error(function (err) {
$scope.error = err;
});
}]);
<div class="container" ng-controller="FlightListController">
<div class="container" ng-controller="FlightListController">