2016-10-27 3 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コードとアラート( "内部メソッド");あなたが書いた関数があなたの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..."); 
    }); 

}); 

通話機能は、定義した後it.Andは、中括弧に注意してください。

+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に問題がありました。ありがとう@pravin

+0

私はこの変数が宣言するAPI_URLの問題を考えると – Pravin

+0

あなたのdataFactoryコードを入れてください – Pravin

+0

私のdataFactoryコードを置くと、ページはinfine回の読み込みを開始します –

関連する問題