javascript - Angular JS is Giving an Undefined Function Error -



javascript - Angular JS is Giving an Undefined Function Error -

i'm writing end application shows listings similar phone book. have filters sorts , pagination well. app loads info first , filtering , pagination done instantly. can't figure out problem here. online , book appears ok. error get:

typeerror: undefined not function @ 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> ...

you phone call function $scope.getlistings() before it's defined.

try :

$scope.getlistings = function () { //function code here } $scope.getlistings();

javascript angularjs

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -