2016-10-27 1 views
-1

enter image description here 정의되지 않습니다

이 코드를 표시 alert- "내부 컨트롤러"그러나 그 후 다음 경고를 표시하지 않고 콘솔

에서 다음과 같은 오류와 함께 중지

$ scope.getResultsPage가 정의되지 않았습니다.

app.controller('CategoryController',function(dataFactory,$scope,$http){ 
      var API_URL = 'http://localhost:90/laravel_new/public'; 
      $scope.categories = []; 
      alert("inside controller"); 

      $scope.getResultsPage(1); 

      $scope.getResultsPage = function(pageNumber){ 
      alert("inside method");  

      dataFactory.httpRequest(API_URL +'/listCategory?page='+pageNumber).then(function(data) { 
       alert("fetchedd..."); 
      }); 

     } 

     }); 

누구나이에 도움을 주시기 바랍니다. 사전에 감사

+0

전화 $ scope.getResultspage (1); $ scope.getResultspage가 함수가 시작되기 전에 끝난 후에. –

+0

브래킷에 몇 가지 문제가 있습니다. – Weedoze

+0

dataFactory.httpRequest 코드를 주석으로 추가하거나 제거하고 alert ("inside method"); 당신이 작성한 함수가 당신의 dataFactory – Pravin

답변

0
app.controller('CategoryController',function(dataFactory,$scope,$http){ 
    $scope.categories = []; 
    alert("inside controller"); 



    $scope.getResultsPage = function(pageNumber){ 
     alert("inside method"); 
    }  

     $scope.getResultsPage(1); 

    dataFactory.httpRequest(API_URL +'/listCategory?page='+pageNumber).then(function(data) { 
     alert("fetchedd..."); 
    }); 

}); 

통화 기능은 정의한 후 그게 뭔지는 중괄호에주의.

+0

여전히 작동하지 않습니다. –

+0

지금 오류가 있습니다. –

0
app.controller('CategoryController',function(dataFactory,$scope,$http){ 
      var API_URL = 'http://localhost:90/laravel_new/public'; 
      $scope.categories = []; 
      alert("inside controller"); 



      $scope.getResultsPage = function(pageNumber){ 
        alert("inside method"); 

      } 

      $scope.getResultsPage(1); 

     }); 

이것은 저에게 효과적입니다. dataFactory에 문제가있었습니다. 감사합니다 @ 프라임

+0

API_URL에서이 변수를 어디에서 선언 할까? – Pravin

+0

dataFactory 코드 – Pravin

+0

내 dataFactory 코드를 입력하면 페이지가 infine 시간을로드하기 시작합니다. –