Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.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
Javascript Angular JS给出了一个未定义的函数错误_Javascript_Angularjs - Fatal编程技术网

Javascript Angular JS给出了一个未定义的函数错误

Javascript Angular JS给出了一个未定义的函数错误,javascript,angularjs,Javascript,Angularjs,我正在编写一个后端应用程序,它显示类似于电话簿的列表。我有一些过滤器,它排序和分页以及。应用程序首先加载所有数据,然后过滤和分页基本上立即完成。我想不出这里有什么问题。从网上和我的书来看,一切似乎都很好。这是我得到的错误: TypeError: undefined is not a function at new <anonymous> (http://local.poha.com/js/ang.js:21:10) var listingsApp = angular.module(

我正在编写一个后端应用程序,它显示类似于电话簿的列表。我有一些过滤器,它排序和分页以及。应用程序首先加载所有数据,然后过滤和分页基本上立即完成。我想不出这里有什么问题。从网上和我的书来看,一切似乎都很好。这是我得到的错误:

TypeError: undefined is not a function
at new <anonymous> (http://local.poha.com/js/ang.js:21:10)

var listingsApp = angular.module('listingsApp', []);

listingsApp.controller('pageController', function ($scope, $http) {

    $scope.GetListings();  <--- line 21

    $scope.GetListings = function () {

        //function code here

    }

})

<html ng-app="listingsApp">
...
<body ng-controller="pageController">

    <div class="pagination">Page: <span ng-repeat="page in pages">
        <a href="" ng-click="GoToPage($index)">{{$index + 1}}</a>&nbsp;&nbsp;</span>
    </div>
    <table id="updateTable" width="2000" cellpadding="4" cellspacing="4" border="0">

    ...

        <tr ng-repeat="listing in allListings">
            <td>{{listing.id}}</td>
            <td>{{listing.name}}</td>
            <td>{{listing.address}}</td>
            <td>{{listing.city}}</td>
            <td>{{listing.state}}</td>
    ...
TypeError:未定义不是函数
在纽约
...
{{listing.id}
{{listing.name}
{{listing.address}
{{listing.city}
{{listing.state}
...

在定义函数$scope.GetListings()之前调用它

尝试:


哇,我不知道,和PHP不同。
   $scope.GetListings = function () {
        //function code here
   }
   $scope.GetListings();