2014-11-09 3 views
-3

전화 번호부와 유사한 목록을 표시하는 백 엔드 응용 프로그램을 작성하고 있습니다. 내가 정렬 및 페이지 매김뿐만 아니라 일부 필터가 있습니다. 앱은 모든 데이터를 먼저로드 한 다음 필터링 및 페이지 매김이 본질적으로 즉시 완료됩니다. 나는 여기서 문제가 무엇인지 알 수 없다. 온라인과 나의 책에서 모든 것이 괜찮은 것처럼 보입니다. 이것은 내가 얻는 오류입니다 :Angular JS에서 정의되지 않은 함수 오류가 발생했습니다.

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

답변

0

정의되기 전에 $ scope.GetListings() 함수를 호출했습니다.

시도 :

$scope.GetListings = function() { 
     //function code here 
    } 
    $scope.GetListings(); 
+0

와우, 내가 PHP와 다른 것을 알고하지 않았다. –

관련 문제