This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
$compile throws error inconsistently if isolated-scope directive's priority is set/unset #4402
Closed
Description
This bit me today. Assume having this directive:
app.directive('dir', function() {
return {
priority: 1,
scope: {},
link: function() {}
}
});
And controller:
<body ng-controller="MainCtrl" dir>
<p>Hello {{name}}!</p>
</body>
The app will fail with:
Error: [$compile:multidir] Multiple directives [dir, ngController] asking for isolated scope on: <body ng-controller="MainCtrl" dir="" class="ng-isolate-scope ng-scope">
However, removing priority
in the directive or set it to 0
, the error disappears. Plunker is here: http://plnkr.co/edit/nElgQQklbiLlD9vuvRov?p=preview.
This is caused by this line: https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L802
Is this intentional or a bug? If it's intentional, shouldn't it fail regardless of directives' priority? I can submit a PR if this is a bug.