Encountering an error "[$rootScope:inprog]" while using Angular select with ngModel

I'm still learning my way around Angular, but I have a basic understanding. Right now, I'm working on assigning access points to a building using a <select> element. I've created a simple controller for this task, but it's not functioning properly. I've been trying to troubleshoot the issue, but so far, no luck.

Edit 1: I can see the three option fields, but every time I select one, an exception is thrown in the browser console.

Edit 2: Plunkr -> https://plnkr.co/edit/EIPs8yVlTSaYQ0EuZLTb (hopefully, this url is functional) .. Once you click on "Neuer Access-Point," the error appears after selecting something from "Gebäude."

Select field

<select ng-model="$ctrl.input.building">
    <option ng-repeat="building in $ctrl.buildings" ng-value="building.id" ng-bind="building.name"></option>
</select>

Controller

(function () {

    function createController(Building) {
        var ctrl = this;

        ctrl.buildings = null;

        ctrl.input = {
            host: '',
            desc: '',
            web: '',
            building: ''
        };

        ctrl.$onInit = function () {
            Building.getAll().then(function (res) {
                if (res.status >= 200 && res.status < 300) {
                    ctrl.buildings = res.data;
                }
            });
        };
    }

    angular.module('app').controller('CreateController', createController)

})();

Error

angular.js:14791 Error: [$rootScope:inprog] http://errors.angularjs.org/1.6.8/$rootScope/inprog?p0=%24apply
    at angular.js:88
at p (angular.js:18897)
at m.$digest (angular.js:18319)
at m.$apply (angular.js:18640)
at Object.$$debounceViewValueCommit (angular.js:29394)
at Object.$setViewValue (angular.js:29372)
at angular.js:33596
at m.$eval (angular.js:18533)
at m.$apply (angular.js:18632)
at HTMLSelectElement.<anonymous> (angular.js:33595)

Answer №1

There seems to be an issue with the code you've provided.

<div id="wrapper" ng-app="accessPoints" ng-controller="RootController **as $root**">

To fix this, you can change it to either of the following:

ng-controller="RootController as anythingButNot$root"

or simply ng-controller="RootController"

Assigning any controller as $root can cause complications. $root serves as the root level controller in your application. If you declare a controller as $root within your HTML, it may conflict with the digest cycle, leading to errors.

For the updated version of the code, you can visit: https://plnkr.co/edit/UcJHVmekMqWMXJBnv2Cu?p=preview

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

Are the sorting algorithms for BackboneJS and AngularJS considered stable sorting methods?

I'm considering incorporating BackboneJS and AngularJS into my app. However, I'm curious about the stability of sorting algorithms in these frameworks. Specifically, I would like to know if they maintain the order of previously sorted columns wit ...

The velocity of jQuery selectors

Which is more efficient: using only the ID as a selector or adding additional identifiers? For instance $('#element') vs $('#container #element') or getting even more detailed: $('body div#container div#element') ? ...

What strategies can I employ to optimize this code in RXJS and Angular?

Is it possible to streamline these nested arrays for more efficient execution after all subscriptions have been completed? I believe there may be a solution involving the use of pipes, mergeMaps, concatMaps, etc. this.teams = [ { Assignments: [{Id: ...

Tips for transferring the input text box value to angularjs when clicking on the text box

Here is the HTML code snippet: <tr ng-repeat="c in client"> <td><input type="text" id="id" value="{{c.id}}" onclick="display();"></input></td> <td><input type="text" value="{{c.fname}}"></td> </ ...

Encountering the error message "Unable to instantiate User: constructor not found" while testing API functionality for

Currently, I am in the process of integrating my backend with MongoDB ATLAS. In order to achieve this, I am utilizing express, mongoose, and node.js for testing purposes. Specifically, I am focusing on testing my API routes, such as adding a user. Below i ...

Using maxDate in Material UI DatePicker Component to set a maximum date limit

I'm having a tough time getting the maxDate property to function properly on the Material UI DatePicker component. It should disable dates after the specified maxDate. In my situation, I needed to set the maxDate to +60 days from the current Date(), ...

Can you run both Angular 6 and AngularJS 1.6 applications on the same computer?

Trying to juggle the development of an Angular 6 app and an AngularJS 1.6 app on the same machine has posed a challenge for me. My current situation involves working on two projects simultaneously - one being a new project utilizing Angular 6 and Angular ...

Tips for broadcasting a router event

Currently, I am working with 2 modules - one being the sidenav module where I can select menus and the other is the content module which contains a router-outlet. I am looking for the best way to display components in the content module based on menu selec ...

Elusive Essence: Mysterious Origins of the

Beginner in the world of Ionic and Angular. I am attempting to create a test app and incorporating the factory function. I obtained the design from Ionic Creator and now trying to add my code to it. Here is my controller file. angular.module('app.c ...

Navigating into the forbidden territory of the if block that holds secrets untold

Encountering an issue with the angularjs $location feature. I have set up an auth interpreter that redirects to the login page if a 401 error (unauthorised) is returned by the server. In my app.js file, both the auth interpreter and the account data loadin ...

Exploring AngularJS: Enhancing User Experience with Dynamic Dropdowns and

I'm currently working with two object structures: one for users and another for groups. The user object includes the group IDs that each user belongs to, while the group object provides information such as ID, name, and type of group (e.g., hierarchy) ...

Add HTML content individually to each item in the array

I am currently developing a plugin and I need to load a preset in order to populate a form with the relevant data. In an attempt to write concise code, I created a variable called "template" that looks like this: var Fields = '<div c ...

Investigating unsuccessful requests in node.js

Here is my code: var request = require('request'); function Service(){ this._config = require('../path/to/config.json'); } Service.prototype.doThing = function(){ return new Promise(function(resolve, reject){ request.post(url, ...

Tips for defining a dynamic class variable in React with Flow

I am working with a map that assigns a reference to items, specifically in this scenario it is a video. const ref = this[`video-${index}-ref`]; I am seeking guidance on how to properly type this using Flow. The number of indexes may vary. ...

Struggling with setting values in AngularJS?

Can you assist me in passing data from: (Page 1 -> Module 1 -> Controller 1) to (Page 2 -> Module 2 -> Controller 2) For example: Module reports - Controller ReportsCtrl //Page 1 <html lang="en" class="no-js" ng-app="reports"> <a ng-href="../n ...

AngularJS Get request unable to fetch image URL due to receiving a "302 found" error

Trying to enhance my AngularJS app by incorporating an image from a random cat image site, using the URL received. Below is the snippet from my controller.js: 'use strict'; /* Controllers */ var catPath = "http://thecatapi.com/api/images/get? ...

Embed message from a Discord Bot

Is it possible to include an image of a bot on the right side of the embedded message? if (message.includes('help')) { msg.channel.send({ embed: { title: "xxxxxx", color: 3447003, description:"Enter **agjgj** to know ...

Navigating through paginated data can be made easier by using Backbone.PageableCollection in conjunction with a personalized

I have developed an application that interacts with a database known as LeanCloud. Currently, I have configured a page to display all the users stored in the database. However, LeanCloud has a limitation where only 100 pieces of data can be retrieved per r ...

Error message saying 'Callback has already been invoked' returned by an async waterfall function

I'm facing an error that I understand the reason for, but I'm unsure how to resolve it. Here's a breakdown of my initial function: Essentially, I am making a get request for all URLs stored in the database and then, for each URL response, I ...

Displaying image while processing substantial ajax data

I implemented code to toggle the display of a loading image on my web page while making ajax requests. $(document).ajaxStart(function(){ $("#please_wait").css("display","block"); }); $(document).ajaxComplete(function(){ $("#please_wait").css(" ...