AngularJS Error: [$compile:ctreq] The controller named xxxx, which is necessary for the directive yyyy, cannot be located

I have searched through multiple topics on stackoverflow regarding this error, but I still can't grasp the issue in my particular scenario.

Here is the template I am using:

<div class="progress">
<div class="progress-bar"
     data-toggle="tooltip"
     title="Parts offertes : {{ '{{ gift.gived_parts}}' }} / {{ '{{ gift.number_of_parts }}' }}"
     data-bar="gived"
     >
    <span ng-class="{true:'op7', false:''}[gift.percent_done > 0 && gift.percent_done < 20]">
        {{ '{{ gift.gived_parts}}' }}
    </span>
</div>
<div class="progress-bar progress-bar-danger progress-bar-striped progress-bar-animate active op7"
     data-toggle="tooltip" 
     title="Parts réservées&nbsp;:&nbsp;{{ '{{ gift.total_reserved}}' }}&nbsp;/&nbsp;{{ '{{ gift.number_of_parts }}' }}"
     data-bar="reserved">
</div>

In relation to this directive:

app.directive('progressBarD', function() {
return {
    restrict: 'E',
    templateUrl: rootUrl + '/directive/progressBar',
    scope: {
        gift: '=gift'
    },
    link: function ($scope, $elem, attrs) {
        var bars = $elem.find(".progress-bar");
        bars.each(function() {
            var bar = $(this);
            var percent = (bar.context.dataset.bar === "gived")
                ? $scope.gift.percent_done
                : $scope.gift.percent_reserved;

            if (($().appear) && isMobileDevice === false && (bars.hasClass("no-anim") === false) ) {
                bar.appear(function () {
                    bar.addClass("progress-bar-animate").css("width", percent + "%");
                }, {accY: -150} );
            } else {
                bar.css("width", percent + "%");
            }
        });
    }
};
});

This is how the directive is implemented:

<progress-bar-d gift="gift"></progress-bar-d>

During execution, an error is encountered:

Error: [$compile:ctreq] Controller 'progress', required by directive 'bar', can't be found!
http://errors.angularjs.org/1.3.15/$compile/ctreq?p0=progress&p1=bar
at angular.js:63
at getControllers (angular.js:7583)
at nodeLinkFn (angular.js:7772)
at angular.js:7998
at processQueue (angular.js:13248)
at angular.js:13264
at Scope.$get.Scope.$eval (angular.js:14466)
at Scope.$get.Scope.$digest (angular.js:14282)
at Scope.scopePrototype.$digest (hint.js:1468)
at Scope.$get.Scope.$apply (angular.js:14571)

The link function seems to be functioning correctly on screen initially, but eventually, the span within the first div disappears when gift.percent_done is not equal to 0.

Can you provide an explanation for this Angular error? Is the deletion of the span causing the same issue?

Answer №1

After much troubleshooting, I was able to pinpoint the issue.

Within the Angular directive, I made a modification to bar.context.dataset.bar and suddenly it started functioning correctly. It's strange that it wasn't working properly before, but at least now it's finally resolved.

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 the AngularJS directive with $http to handle JSON responses

Following the steps mentioned here I am using Ajax to retrieve server data which is in Json format containing markup with a directive. I am attempting to use $compile to trigger this directive, but so far, I have been unsuccessful. Below is the controlle ...

Guide on how to pass the chosen dropdown value from a custom component back to the main component

I've developed a customized MUI select component in React and have integrated it multiple times within another component as shown: customDropdown.js import * as React from 'react'; import FormControl from '@mui/material/FormControl&ap ...

Prevent users from copying and pasting text or right-clicking on the website

I have been struggling to completely disable the ability for users to copy and paste or select text on my website across all devices. After much searching, I came across a solution that I implemented on my site. Below the <body> tag, I inserted the ...

Tips for accessing child elements within an Angular component

I'm struggling to get a reference of child elements within a component. I have experimented with ElementRef, TemplateRef, QueryList, ViewChild, ViewChildren, ContentChild, and ContentChildren without success. <app-modal> <section #referenc ...

Issue with hidden sourcemap not loading in Chrome or Firefox during Vite build

Transitioning my react application from create-react-app to Vite has resulted in some unexpected behavior with source maps. To learn more about Vite's documentation on source maps, click here. Initially, I was thinking of using sourcemap: true, but th ...

Tips for implementing a minimum character length feature in React Material-UI's Autocomplete feature

I am looking to add a 'minimum character length' feature to the autocomplete component in react material-ui. The code snippet below demonstrates what I have so far. constructor(props) { super(props); this.state = { // toggle for ma ...

Find the coordinate of a point in a three-dimensional space that lies at a given distance between two specified points

In order to achieve a smooth camera movement in three.js, it is essential to compute the position of point C. This calculation will ensure that the camera can smoothly transition from point A to a specific distance away at point B. ...

How can the backgroundImage css in react admin <Login /> be replaced using Material-UI?

I have been refering to the following resources: Learn about customizing login page background in React-Admin: Explore themes customization in Material-UI: https://material-ui.com/customization/components/ Instead of using a preset background, I want to ...

Creating a dynamic sliding feature in Three.js: A step-by-step guide

Recently, I came across three.js and fell in love with it. I managed to create a rotating car animation controlled by keyboard arrows, but now I'm facing a challenge in creating a sliding animation (similar to -> -> ->) instead of a rotation ...

The select2 function fails to append data effectively

I recently implemented the select2 plugin found at . In my form, I have a feature where users can add new lines. What I do is grab the HTML code from the previous line and append it to the form for the new line. While this method has successfully added t ...

Using the "i" parameter in a Lodash for loop results in undefined, however, it functions properly with specific values set

My goal is to use Lodash to search for specific integer values in an object and then store some of those values in an array. The integers are variable and come from a separate array, but I am consistently getting undefined as the result. If I manually inp ...

Searching with RegEx results in a negative value, despite the fact that the specified phrase is clearly within the array

When importing an excel file into Angular using the xlsx library, the file is converted into an object of arrays. Each array represents a row from the excel file, and each item within the array corresponds to a cell in that row. The process for importing t ...

When attempting to refresh the page, an error occurred stating: 'Unhandled TypeError: Cannot access properties of undefined (reading FetchApi.js:23 'data')'

Upon the initial run of the code, the mappings data appear as desired. However, upon refreshing the page, an error is displayed. Can someone please advise on how to rectify this error and what could be causing it? The provided code: import React, { useE ...

Updates to directive scope variables do not reflect changes in the parent scope variables, according to Angular Js 1.5

This is my custom controller function customController($stateParams, customFactory, $rootScope){ const ctrl = this; ctrl.customData = {}; ctrl.result = {}; ctrl.$onInit = function(){ ctrl.result.isVisible = false; } export {customControlle ...

Utilizing ES6 Proxy leads to the occurrence of an error message stating "this is not a function" whenever a function call

As I ventured into the depths of ES6 Proxies, attempting to be a crafty developer, I found myself entangled in their complexities. My goal was to intercept any get or set operation on a property from a class I had written and ensure that they were stored e ...

Exploring the functionalities of Dojo Grid in conjunction with a Memory store

I'm struggling to make the Dojo Grid widget function properly. The grid itself is included declaratively: <table data-dojo-type="dojox.grid.DataGrid" data-dojo-attach-point="relationshipsGrid"></table> Next, I am attempting to connect t ...

Is e.preventDefault() failing to work in Next.js?

Hey everyone, I'm new to react.js and next.js. I attempted to copy some data from a form and display it in the console, but using e.preventDefault() is preventing me from submitting my form. Is there a more effective way to achieve what I'm aimin ...

The "begin" parameter of the Angular limitTo filter appears to be ineffective in Angular version 1.3

Currently, I am attempting to implement a pagination feature on an array of users using Angularjs 1.3. ng-repeat="user in users | filter: searchText | orderBy: 'lastName' | limitTo:pageSize:startPosition track by user.lanId" I specifically want ...

While utilizing Yeoman build, an error occurs: "Uncaught Error: Unknown provider: aProvider <- a"

After running the yeoman build command and trying to access my web app, I encountered the following error An Uncaught Error occurred: Unknown provider: aProvider <- a ...

The object continues to be undefined despite its placement in a global scope

Currently, I am working on building a game of pong and encountering an issue with creating a paddle in the initialize method. Despite storing it as a global variable, the paddle remains undefined. I even tried making it a property of 'window', bu ...