This repository was archived by the owner on Apr 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 743
/
Copy path$compile:ctreq.html
36 lines (36 loc) · 2.43 KB
/
$compile:ctreq.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<a href="http://github.com/angular/angular.js/edit/master/docs/content/error/compile/ctreq.ngdoc" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">Missing Required Controller</code>
<div><span class="hint">error in component <code ng:non-bindable="">$compile</code>
</span>
</div>
</h1>
<div><pre class="minerr-errmsg" error-display="Controller '{0}', required by directive '{1}', can't be found!">Controller '{0}', required by directive '{1}', can't be found!</pre>
<h2 id="description">Description</h2>
<div class="description"><div class="-compile-page -compile-ctreq-page"><p>This error occurs when <a href="api/ng.$compile"><code>HTML compiler</code></a> tries to process a directive that specifies the <a href="api/ng.$compile#description_comprehensive-directive-api_directive-definition-object"><code><code>require</code> option</code></a> in a <a href="api/ng.$compile#description_comprehensive-directive-api"><code>directive definition</code></a>,
but the required directive controller is not present on the current DOM element (or its ancestor element, if <code>^</code> was specified).</p>
<p>To resolve this error ensure that there is no typo in the required controller name and that the required directive controller is present on the current element.</p>
<p>If the required controller is expected to be on a ancestor element, make ensure that you prefix the controller name in the <code>require</code> definition with <code>^</code>.</p>
<p>If the required controller is optionally requested, use <code>?</code> or <code>^?</code> to specify that.</p>
<p>Example of a directive that requires <a href="api/ng.directive:ngModel"><code>ngModel</code></a> controller:</p>
<pre><code>myApp.directive('myDirective', function() {
return {
require: 'ngModel',
...
}
}</code></pre>
<p>This directive can then be used as:</p>
<pre><code><input ng-model="some.path" my-directive></code></pre>
<p>Example of a directive that optionally requires a <a href="api/ng.directive:form"><code>form</code></a> controller from an ancestor:</p>
<pre><code>myApp.directive('myDirective', function() {
return {
require: '^?form',
...
}
}</code></pre>
<p>This directive can then be used as:</p>
<pre><code><form name="myForm">
<div>
<span my-directive></span>
</div>
</form></code></pre>
</div></div>
</div>