The Ng-View feature is failing to provide the expected output, instead generating an error message stating "RangeError: Maximum call stack size exceeded

Having trouble with Ng-View not displaying the output correctly. When attempting to route from one page to another, I keep encountering the error message:

"RangeError: Maximum call stack size exceeded"

Please review the following code and provide suggestions on how to resolve this issue:

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

Answer №1

Initially, let's address the issue of infinite recursion. It appears that your menuCtrl is being loaded twice:

  1. First instance is in the HTML file

    ng-controller="menuCtrl"
    
  2. Second instance is in the route configuration

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

It's crucial to rectify this issue before proceeding, as it may impact the functionality of your application based on the content of other HTML templates.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Npm to install a module results in an abundance of files being provided

Back when I used npm install 6 months ago to install a module, it would create a new folder under node_modules containing all the files for that module. However, now when I use it, it creates multiple files for one module. How can I install a module to a ...

Transmit console log data to a PHP webpage

Is there a way to pass the values collected from a Bootstrap table using console.log to a URL via POST method upon button click? var $table = $('#table'); var $button = $('#button'); function getRowSelections() { re ...

Tips for creating Firestore rules for a one-on-one messaging application

After creating a one to one chat app for a website using Firebase and Firestore, I am now looking to set up the Firebase Firestore rules for the same. The functionality of the app involves checking if the user is [email protected], then retrieving chatids ...

Securing URL Query Parameters

Working with Liferay 5.2 and ExtJS 3.4 poses a challenge for parameter passing in the URL. The issue arises when reports are generated based on parameters passed in the URL, allowing manual changes that lead to the generation of unauthorized reports. The ...

Encountering a 500 error in Angular while utilizing forkJoin for calling API services

In my Angular 7 project, I have implemented a call in the ngOnInit method to two different API routes to fetch some data using forkJoin. Here is how I have set it up: ngOnInit() { debugger this.route.params.pipe( switchMap(params => for ...

Issues with webpage responsiveness, width not adjusting correctly

Just completed coding my website and now I'm facing a new challenge. I am focusing on making it responsive for tablet screens (768px) starting with the header section, but for some reason, the modifications I make in the responsive.css file are not ta ...

I am having trouble getting Form.Select to work in my basic react-bootstrap application, despite following the guidelines provided in the react-bootstrap documentation. Can

I am new to utilizing "react-bootstrap with hooks" and currently in the process of creating a basic form. I have been following the guidance provided by react-bootstrap documentation, but I encountered an issue specifically with select/option form elements ...

Having issues with Facebook's login API for JavaScript?

Apologies for the improper formatting. I am encountering errors in my JavaScript compiler while working with the Facebook Login API... Error: Invalid App Id - Must be a number or numeric string representing the application id." all.js:53 "FB.getL ...

Tips for submitting a request following a change in the variable

I am in the process of developing a React application and I have implemented Auth0 for authentication. My goal is to initiate an HTTP request upon page refresh, but only if the variable isLoading is false. This way, I can access the user object once the ...

How does Backbone.js tackle error handling when receiving messages from Rails?

Can anyone using backbone.js lend a hand? How can error messages from a rails app be encoded when integrating with backbone.js? For instance, how should flash messages like "record not found" be handled? While errors are usually defined on the client sid ...

Transmitting Various Static Files via Express Router

I am currently utilizing the Express router to serve static .html files based on the URL specified in router.get. For example, this code snippet sends the homepage: router.get('/', function(req, res, next) { res.sendFile('index.html&ap ...

Transitioning JS/CSS effects when the window is inactive

My latest project involved creating a small slider using JavaScript to set classes every X seconds, with animation done through CSS Transition. However, I noticed that when the window is inactive (such as if you switch to another tab) and then return, the ...

Securing Your Content - Preventing Users from Right-Clicking and Using F12 on Your Website

I am looking to disable the Right-Click function on my website or display an error message saying "Protected Content!" when someone tries to right-click. I want to prevent others from viewing my Source Code. Although I know how to disable Right-Click, I am ...

Is it possible for jQuery to create a popup window displaying a specific value?

Using JavaScript, I have implemented functionality to open a child window when the user clicks on a button from the parent window. The child window contains a textbox and a button. When the user clicks on the button in the child window, I want to retrieve ...

Load annotations from a JSON file with Annotator.js

Seeking assistance with incorporating annotations into my website using annotator.js. I have been encountering difficulties getting it up and running successfully. My goal is to display highlighted annotations upon page load, but I keep receiving a JavaSc ...

Can the Twitter Bootstrap typeahead feature be used with an external data source?

Can the typeahead feature in version 2.0.3 of twitter-bootstrap work with a remote data source? You can check out the link for more information on the typeahead functionality: ...

In JavaScript, the return statement is used to halt the execution of any subsequent statements

I encountered a situation where I need to stop the execution of the next function call if the previous function has a return statement. However, I noticed that even though there is a return statement in the "b" function below, the next function call still ...

Difficulty encountered with Mongoose/MongoDb FindOneAndUpdate functionality

My goal is to update a specific location only if it has a status of 0 or 2, but not if the status is 1. There is only one instance of this location in my database. Property.findOneAndUpdate({ status: 0, location: req.body.update.location }, req.body.updat ...

What is the best way to conceal the header on a 404 error page?

<HeaderContainer> <Switch> <Route exact path='/counters' component={ParentCounterContainer}/> <Route exact path='/about' component={AboutContainer} /> <Route exact path='/' component={H ...

Static addition of the Button to the parent div is crucial for seamless

Introduction: My current project involves managing interns, and I am focusing on the employee side. Employees have the ability to add, edit, and delete interns through modal popups. Strategy: To avoid unnecessary repetition of code, I decided to create a ...