简体   繁体   English

Angular js错误:找不到指令yyyy所需的[$ compile:ctreq]控制器xxxx

[英]Angular js Error: [$compile:ctreq] Controller xxxx, required by directive yyyy, can't be found

I already multiple topics on stackoverflow about this error but I always don't understand the problem in my context. 我已经在关于这个错误的stackoverflow上有多个话题,但是我始终无法理解我的问题。

I have this template: 我有这个模板:

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

For 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 + "%");
            }
        });
    }
};
});

And here is the call of the directive: 这是指令的调用:

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

During the execution, I obtain this error: 在执行期间,我得到此错误:

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)

On the screen, the link function look to work, but at the end, the inside the first desapear when gift.percent_done is different of 0. 在屏幕上,链接功能看起来可以工作,但是最后,当gift.percent_done的值不等于0时,第一次出现内部缺失。

Could you explain me why I have this angular error ? 你能解释一下为什么我有这个角度误差吗? Do the deletion of the span is the same problem ? 删除跨度是否是同样的问题?

Finally I found the problem. 终于我找到了问题。

In the anguluar directive I change bar.context.dataset.bar and it work. 在anguluar指令中,我更改了bar.context.dataset.bar并且它起作用。 I don't know why that was not well interpreted but now it work. 我不知道为什么不能很好地解释它,但是现在可以了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:[$ compile:ctreq]指令所需的控制器,找不到 - Error: [$compile:ctreq] Controller required by directive , can't be found Angularjs:错误:[$compile:ctreq] 指令“ngTransclude”所需的控制器“carousel”,无法找到 - Angularjs: Error: [$compile:ctreq] Controller 'carousel', required by directive 'ngTransclude', can't be found Angular JS缺少必需的控制器错误:找不到指令所需的控制器“ ngModel” - Angular JS Missing Required Controller error: Controller 'ngModel', required by directive can't be found 错误:$ compile:ctreq缺少必需的控制器 - Error: $compile:ctreq Missing Required Controller $ compile:角度代码中的ctreq错误 - $compile:ctreq error in angular code AngularJS错误:指令“ drawing”所需的控制器“ drawing”找不到 - AngularJS Error: Controller 'drawing', required by directive 'drawing', can't be found 包装时找不到指令“ uibSlide”所需的控制器“ uibCarousel” - Controller 'uibCarousel', required by directive 'uibSlide', can't be found when wrapping 无法找到指令'ngTransclude'所需的控制器'carousel' - Controller 'carousel', required by directive 'ngTransclude', can't be found Contidional 模板 - 无法找到指令“mdRadioButton”所需的控制器“mdRadioGroup” - Contidional template - Controller 'mdRadioGroup', required by directive 'mdRadioButton', can't be found 找不到指令“ loginForm”所需的控制器“ alertForm”! 在angularjs中 - Controller 'alertForm', required by directive 'loginForm', can't be found! in angularjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM