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> </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();