blob: b8d5590dc3699878776067a694e67b7e9cbaf3dd (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
|
@ngdoc error
@name $compile:ctreq
@fullName Missing Required Controller
@description
This error occurs when {@link api/ng.$compile template compiler} tries process the directive that specifies the `require` option in a {@link guide/directive#directivedefinitionobject directive definition},
but the required directive controller is not present on the current DOM element (or its ancestor element, if `^` was specified).
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.
If the required controller is expected to be on a ancestor element, make ensure that you prefix the controller name in the `require` definition with `^`.
If the required controller is optionally requested, use `?` or `^?` to specify that.
Example of a directive that requires {@link api/ng.directive:ngModel ngModel} controller:
```
myApp.directive('myDirective', function() {
return {
require: 'ngModel',
...
}
}
```
This directive can then be used as:
```
<input ng-model="some.path" my-directive>
```
Example of a directive that optionally requires a {@link api/ng.directive:form form} controller from an ancestor:
```
myApp.directive('myDirective', function() {
return {
require: '^?form',
...
}
}
```
This directive can then be used as:
```
<form name="myForm">
<div>
<span my-directive></span>
</div>
</form>
```
|