Skip to content

Commit e1ce105

Browse files
committed
docs($compileProvider): improve strictComponentBindingsEnabled info
Related to angular#16303
1 parent 9871ada commit e1ce105

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

docs/content/error/$compile/missingattr.ngdoc

+33-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,36 @@
33
@fullName Missing required attribute
44
@description
55

6-
This error may occur only when `$compileProvider.strictComponentBindingsEnabled` is set to `true`.
7-
Then all attributes mentioned in `bindings` without `?` must be set. If one or more aren't set,
8-
the first one will throw an error.
6+
This error may occur only when {@link $compileProvider#strictComponentBindingsEnabled `$compileProvider.strictComponentBindingsEnabled`} is set to `true`.
7+
8+
If that is the case, then all {@link $compileProvider#component component} controller bindings and
9+
{@link $compileProvider#directive directive} scope / controller bindings that are non-optional,
10+
must be included when the directive is used.
11+
12+
To make a binding optional, add '?' to the definition.
13+
14+
### Example:
15+
16+
```js
17+
18+
app.component('myTest', function() {
19+
return {
20+
bindings: {
21+
first: '=?', // this one is optional
22+
second: '='
23+
},
24+
controller: function() {
25+
...
26+
},
27+
template: '...'
28+
}
29+
});
30+
31+
```
32+
33+
This component will throw `missingattr` when used as follows:
34+
35+
```html
36+
<myTest></myTest>
37+
```
38+

src/ng/compile.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1422,9 +1422,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
14221422
* @kind function
14231423
*
14241424
* @description
1425-
* Call this method to enable/disable strict component bindings check. If enabled, the compiler will enforce that
1426-
* for all bindings of a component that are not set as optional with `?`, an attribute needs to be provided
1427-
* on the component's HTML tag.
1425+
* Call this method to enable / disable the strict component bindings check. If enabled, the
1426+
* compiler will enforce that for all scope / controller bindings of
1427+
* a {@link $compileProvider#directive directive} / {$compileProvider#component component}
1428+
* that are not set as optional with `?`, an attribute needs to be provided on the
1429+
* component's HTML tag. If not set, the compiler will throw the {@link error/$compile/missingattr
1430+
* $compile:missingattr error}.
14281431
*
14291432
* The default value is false.
14301433
*/

0 commit comments

Comments
 (0)