Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJS一直告诉我我的控制器不是一个函数_Angularjs - Fatal编程技术网

AngularJS一直告诉我我的控制器不是一个函数

AngularJS一直告诉我我的控制器不是一个函数,angularjs,Angularjs,在浏览器中运行应用程序时,控制台会告诉我: 错误:[ng:areq]参数“FlightListController”不是函数,未定义 “FlightListController”通过“ng视图”绑定到my index.html 现在我不知道角度误差想告诉我什么。隐藏在错误背后的错误并没有真正的帮助 var app = angular.module("flightlog"); app.controller("FlightListController", ['$scope', '$http', f

在浏览器中运行应用程序时,控制台会告诉我:

错误:[ng:areq]参数“FlightListController”不是函数,未定义

“FlightListController”通过“ng视图”绑定到my index.html

现在我不知道角度误差想告诉我什么。隐藏在错误背后的错误并没有真正的帮助

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">