2017-03-16 71 views
0

Ng-View沒有給出輸出。嘗試將頁面路由到另一個頁面,而不是我得到這個錯誤。Ng-View沒有給出輸出「RangeError:超出最大調用堆棧大小」

"RangeError: Maximum call stack size exceeded"

請檢查以下內容並給出建議以解決該問題。 App.jss

'use strict';

var app = angular.module('Sab', ['ui.filters','ui','ngRoute']) 

.config(["$routeProvider", function($routeProvider) { 
    $routeProvider. 
     when('/home', { 
      templateUrl: 'index.html', 
      controller: 'menuCtrl' 
     }). 
     when('/Deals/:offer_name', { 
      templateUrl: 'Deals.html', 
      controller: 'abCtrl' 
     }). 
     when('/D', { 
      templateUrl: 'D.html', 

     }). 
     otherwise({ 
      redirectTo: '/home' 
     }); 
}]) 


.controller('menuCtrl', function($scope,$http) { 


    $http.get("http://tools.vcommission.com/api/coupons.php?apikey=e159f64e3dd49fddc3bb21dcda70f10c6670ea91aac30c7cb1d4ed37b20c45b8").then(function (response) { 
     $scope.myData = response.data; 
     $scope.offerName = ''; //set initially 
     $scope.selectedIndex = -1; 
     $scope.filteredOffers = []; 



    }); 
$scope.showData = function(offer_name, index) { 
     $scope.offerName = offer_name; 
     $scope.filteredOffers = $scope.myData.filter(function(offer) { 
     return offer.offer_name == $scope.offerName; 
     }); 
     $scope.selectedIndex = index; 

     } 


}) 

.controller('abCtrl',function($scope,$http,$stateParams,$filter,$window) { 


$http.get("http://tools.vcommission.com/api/coupons.php?apikey=e159f64e3dd49fddc3bb21dcda70f10c6670ea91aac30c7cb1d4ed37b20c45b8").then(function (response) { 


     var offerName = $stateParams.offer_name; 
     $scope.filteredOffers = $filter('filter')(response.data, {offer_name: offerName}); 
    // $scope.filteredOffers = _.filter(response.data, ["offer_name",offerName]); 

     console.log($scope.filteredOffers) 
     console.log(offerName) 


     $scope.dealopen = function($a){ 
      for (var i=0;i<response.data.length;i++) 
     { 
      //console.log($scope.data[i].name); 
      $link=response.data[i].link; 

      if ($link==$a) 
      { 

      $window.open($link,"_self","location=yes"); 
      console.log($a); 
      } 




     } 



     } 
     }); 


}); 

的Html

<div class="row" ng-app="Sab" ng-controller="menuCtrl" > 
        <ng-view></ng-view> 

        <div class="col col-100 " ng-repeat="da in myData | unique: 'store_image'" > 
      <div class="card col " > 

        <img class=" img-responsive " ng-src="{{ da.store_image}}" 
ng-click="showData(da.offer_name, $index)" 
        /> 
       <div class="caption"> 
        <a class="item item-text-wrap" href="#/Deals/{{da.offer_name }}" ng-click="showData(da.offer_name, $index)" 
> 
        <b class="group inner list-group-item-heading center-block"> 
         {{da.category }} Deals </b> 

       </a> 

        </div> 
        </div> 
       </div> 
      </div> 









        </div> 
+0

您要調用的數據是_huge_。這是一個2 MB的陣列。這可能與「超出最大調用堆棧」有關。 –

+0

但那在離子中工作正常..以及如何克服這個 –

+0

它似乎不像連接到大數據。更多看起來像無限嵌套路由或某種其他類型的無限遞歸。你能爲我們提供一個小提琴嗎? –

回答

0

首先,這涉及到心靈 - 無限遞歸。首先,你menuCtrl被加載兩次:

  1. 在HTML

    ng-controller="menuCtrl" 
    
  2. 在路線

    when('/home', { 
        templateUrl: 'index.html', 
        controller: 'menuCtrl' 
    }) 
    

讓我們從解決這個開始。下一個取決於,我想你的其他HTML模板。

+0

兩次?先生在哪裏.. –

+0

先生,我們可以聊天.. –

+0

是的,我們可以。怎麼樣? Skype的? –

相關問題