|
38 | 38 | from the annotated component as type arguments to its children. See its
|
39 | 39 | documentation for details.
|
40 | 40 |
|
| 41 | +* [#930][]: Added `@visibleForTemplate` to `package:angular/meta.dart`. This |
| 42 | + is an _optional_ annotation that may be used to annotate elements that |
| 43 | + should _only_ be used from within generated code (i.e. a `.template.dart`). |
| 44 | + It is a compile-time _hint_, which may be treated as a failing build, to use |
| 45 | + annotated elements outside of the component or template. |
| 46 | +
|
| 47 | + This annotation is intended to give component authors more control in |
| 48 | + specifying the public API of their component(s), especially coupled with the |
| 49 | + fact that AngularDart requires all members to be public to be reachable from |
| 50 | + generated code. For example, `c` and `ngAfterChanges` are only accessible |
| 51 | + from `CalculatorComponent` (or its template) in the following: |
| 52 | +
|
| 53 | + ```dart |
| 54 | + import 'package:angular/angular.dart'; |
| 55 | + import 'package:angular/meta.dart'; |
| 56 | +
|
| 57 | + @Component( |
| 58 | + selector: 'calculator-comp', |
| 59 | + template: '{{a}} + {{b}} = {{c}}', |
| 60 | + ) |
| 61 | + class CalculatorComponent implements AfterChanges { |
| 62 | + @Input() |
| 63 | + num a = 0; |
| 64 | +
|
| 65 | + @Input() |
| 66 | + num b = 0; |
| 67 | +
|
| 68 | + @visibleForTemplate |
| 69 | + num c = 0; |
| 70 | +
|
| 71 | + @override |
| 72 | + @visibleForTemplate |
| 73 | + void ngAfterChanges() { |
| 74 | + c = a + b; |
| 75 | + } |
| 76 | + } |
| 77 | + ``` |
| 78 | +
|
| 79 | + **NOTE**: This feature is only _enforced_ in SDK: `>=2.1.0-dev.3.1`. |
| 80 | +
|
41 | 81 | ### Bug fixes
|
42 | 82 |
|
43 | 83 | * [#1538][]: A compile-time error is reported if the `@deferred` template
|
|
117 | 157 |
|
118 | 158 | [#434]: https://github.com/dart-lang/angular/issues/434
|
119 | 159 | [#880]: https://github.com/dart-lang/angular/issues/880
|
| 160 | +[#930]: https://github.com/dart-lang/angular/issues/930 |
120 | 161 | [#1500]: https://github.com/dart-lang/angular/issues/1500
|
121 | 162 | [#1502]: https://github.com/dart-lang/angular/issues/1502
|
122 | 163 | [#1538]: https://github.com/dart-lang/angular/issues/1538
|
|
0 commit comments