Skip to content

Doc fixes #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1190,8 +1190,7 @@ String _getEventName(ast.EventAst event) =>

/// Visitor which filters elements that are not supported in angular templates.
class _ElementFilter extends ast.RecursiveTemplateAstVisitor<void> {
static const _securityUrl =
'https://webdev.dartlang.org/angular/guide/security';
static const _securityUrl = 'https://angulardart.xyz/guide/security';

@override
ast.ElementAst? visitElement(ast.ElementAst astNode, [_]) {
Expand Down
6 changes: 3 additions & 3 deletions ngdart/lib/angular.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
/// * [AngularDart guide][]
/// * [AngularDart cheat sheet][cheatsheet]
///
/// [AngularDart]: https://webdev.dartlang.org/angular
/// [AngularDart guide]: https://webdev.dartlang.org/angular/guide
/// [cheatsheet]: https://webdev.dartlang.org/angular/cheatsheet
/// [AngularDart]: https://angulardart.xyz
/// [AngularDart guide]: https://angulardart.xyz/guide
/// [cheatsheet]: https://angulardart.xyz/cheatsheet

library;

Expand Down
2 changes: 1 addition & 1 deletion ngdart/lib/experimental.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export 'src/meta.dart' show changeDetectionLink;
///
/// Requires [userInjector] to provide app-level services or overrides:
/// ```dart
/// main() {
/// void main() {
/// var injector = rootInjector((parent) {
/// return Injector.map({ /* ... */ }, parent);
/// });
Expand Down
17 changes: 9 additions & 8 deletions ngdart/lib/src/bootstrap/run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Injector appInjector(
/// An implementation of [Injector] that invokes closures.
///
/// ... right now this is a workaround for the ApplicationRef issue above.
@Immutable()
@immutable
class _LazyInjector extends HierarchicalInjector {
final Map<Object, Object Function()> _providers;

Expand Down Expand Up @@ -99,8 +99,8 @@ Injector _identityInjector(Injector parent) => parent;
/// Starts a new AngularDart application with [componentFactory] as the root.
///
/// ```dart
/// // Assume this file is "main.dart".
/// import 'package:ngdart/angular.dart';
///
/// import 'main.template.dart' as ng;
///
/// @Component(
Expand All @@ -123,8 +123,9 @@ Injector _identityInjector(Injector parent) => parent;
/// Optionally may supply a [createInjector] function in order to provide
/// services to the root of the application:
///
/// // Assume this file is "main.dart".
/// ```dart
/// import 'package:ngdart/angular.dart';
///
/// import 'main.template.dart' as ng;
///
/// @Component(
Expand All @@ -143,14 +144,14 @@ Injector _identityInjector(Injector parent) => parent;
/// }
/// }
///
/// void main() {
/// runApp(ng.HelloWorldNgFactory, createInjector: helloInjector);
/// }
///
/// @GenerateInjector(const [
/// const ClassProvider(HelloService),
/// const ClassProvider(HelloService)
/// ])
/// final InjectorFactory helloInjector = ng.helloInjector$Injector;
///
/// void main() {
/// runApp(ng.HelloWorldNgFactory, createInjector: helloInjector);
/// }
/// ```
///
/// See [InjectorFactory] for more examples.
Expand Down
14 changes: 7 additions & 7 deletions ngdart/lib/src/common/directives/ng_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import 'package:web/web.dart';
///
/// - [String] - all the CSS classes listed in a string (space delimited) are
/// added
/// - [List] - all the CSS classes (List elements) are added
/// - [Object] - each key corresponds to a CSS class name while values are
/// - [List] - all the CSS classes (List elements) are added
/// - [Map] - each key corresponds to a CSS class name while values are
/// interpreted as expressions evaluating to [bool]. If a given expression
/// evaluates to [true] a corresponding CSS class is added - otherwise it is
/// evaluates to `true` a corresponding CSS class is added - otherwise it is
/// removed.
///
/// While the [NgClass] directive can interpret expressions evaluating to
/// [String], [Array] or [Object], the [Object]-based version is the most often
/// [String], [List] or [Map], the [Map]-based version is the most often
/// used and has an advantage of keeping all the CSS class names in a template.
///
/// ### Examples
Expand All @@ -45,8 +45,8 @@ import 'package:web/web.dart';
/// For details, see the [`ngClass` discussion in the Template Syntax][guide]
/// page.
///
/// [ex]: https://angulardart.dev/examples/template-syntax#ngClass
/// [guide]: https://webdev.dartlang.org/angular/guide/template-syntax.html#ngClass
/// [ex]: https://angulardart.xyz/examples/template-syntax#ngClass
/// [guide]: https://angulardart.xyz/guide/template-syntax.html#ngClass
@Directive(
selector: '[ngClass]',
)
Expand Down Expand Up @@ -144,7 +144,7 @@ class NgClass implements DoCheck, OnDestroy {
}

/// If [rawClassVal] is an `Iterable`, it should only contain string values,
/// but it is OK if the `Iterable` itself is [Iterable<dynamic>] or
/// but it is OK if the `Iterable` itself is `Iterable<dynamic>` or
/// `Iterable<Object?>` since we need to walk it in this method anyway.
///
/// Likewise, if [rawClassVal] is a Map, its keys should all be strings.
Expand Down
2 changes: 1 addition & 1 deletion ngdart/lib/src/common/directives/ng_for.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import '../../core/linker.dart';
/// For details, see the [`ngFor` discussion in the Template Syntax][guide]
/// page.
///
/// [guide]: https://webdev.dartlang.org/angular/guide/template-syntax.html#ngFor
/// [guide]: https://angulardart.xyz/guide/template-syntax.html#ngFor
@Directive(
selector: '[ngFor][ngForOf]',
)
Expand Down
5 changes: 3 additions & 2 deletions ngdart/lib/src/common/directives/ng_for_identity.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// @docImport 'ng_for.dart';
library;

import 'package:meta/meta.dart';
import 'package:ngdart/src/core/linker/template_ref.dart';
import 'package:ngdart/src/core/linker/view_container_ref.dart';
Expand All @@ -15,8 +18,6 @@ import 'package:ngdart/src/meta.dart';
/// * Uses _identity_ not _contents_ of a collection to build child views.
/// * Assumes all collections' contents will never change.
/// * Only supports the `$implicit` and `index` local variables.
///
/// This API is **experimental** and subject to change or removal.
@Directive(
selector: '[ngForIdentity][ngForIdentityOf]',
)
Expand Down
2 changes: 1 addition & 1 deletion ngdart/lib/src/common/directives/ng_if.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import 'package:ngdart/src/runtime/check_binding.dart';
/// </template>
/// ```
///
/// [guide]: https://webdev.dartlang.org/angular/guide/template-syntax.html#ngIf
/// [guide]: https://angulardart.xyz/guide/template-syntax.html#ngIf
@Directive(
selector: '[ngIf]',
)
Expand Down
17 changes: 5 additions & 12 deletions ngdart/lib/src/common/directives/ng_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import 'package:web/web.dart';

/// The `NgStyle` directive changes an element's style based on the bound style
/// expression:
///
/// <div [ngStyle]="styleExp"></div>
///
/// ```html
/// <div [ngStyle]="styleExp"></div>
/// ```
/// _styleExp_ must evaluate to a `Map<String, String>`. Element style properties
/// are set based on the map entries: each _key_:_value_ pair identifies a
/// style property _name_ and its _value_.
Expand Down Expand Up @@ -43,15 +43,8 @@ import 'package:web/web.dart';
/// In this example, user changes to the `<input>` elements result in updates
/// to the corresponding style properties of the first paragraph.
///
/// A [Map] literal can be used as a style expression:
///
/// <div [ngStyle]="{'font-style': 'italic'}"></div>
///
/// A better practice, however, is to bind to a component field or method, as
/// in the binding to `setStyle()` above.
///
/// [guide]: https://webdev.dartlang.org/angular/guide/template-syntax.html#ngStyle
/// [ex]: https://angulardart.dev/examples/template-syntax#ngStyle
/// [guide]: https://angulardart.xyz/guide/template-syntax.html#ngStyle
/// [ex]: https://angulardart.xyz/examples/template-syntax#ngStyle
@Directive(
selector: '[ngStyle]',
)
Expand Down
4 changes: 2 additions & 2 deletions ngdart/lib/src/common/directives/ng_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class SwitchView {
/// Try the [live example][ex].
/// For details, see the [Structural Directives section on `ngSwitch`][guide].
///
/// [ex]: https://angulardart.dev/examples/template-syntax#ngSwitch
/// [guide]: https://webdev.dartlang.org/angular/guide/structural-directives.html#ngSwitch
/// [ex]: https://angulardart.xyz/examples/template-syntax#ngSwitch
/// [guide]: https://angulardart.xyz/guide/structural-directives.html#ngSwitch
///
@Directive(
selector: '[ngSwitch]',
Expand Down
38 changes: 20 additions & 18 deletions ngdart/lib/src/common/pipes/async_pipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ final _observableStrategy = _ObservableStrategy();
/// <?code-excerpt "common/pipes/lib/async_pipe.dart (AsyncPipe)"?>
/// ```dart
/// @Component(
/// selector: 'async-greeter',
/// template: '''
/// <div>
/// <p>Wait for it ... {{ $pipe.async(greeting) }}</p>
/// <button [disabled]="!done" (click)="tryAgain()">Try Again!</button>
/// </div>''')
/// selector: 'async-greeter',
/// template: '''
/// <div>
/// <p>Wait for it ... {{ $pipe.async(greeting) }}</p>
/// <button [disabled]="!done" (click)="tryAgain()">Try Again!</button>
/// </div>
/// ''',
/// )
/// class AsyncGreeterPipe {
/// static const _delay = const Duration(seconds: 2);
///
/// Future<String> greeting;
/// bool done;
/// late Future<String> greeting;
/// late bool done;
///
/// AsyncGreeterPipe() {
/// tryAgain();
Expand All @@ -64,25 +66,25 @@ final _observableStrategy = _ObservableStrategy();
///
/// void tryAgain() {
/// done = false;
/// greeting = new Future<String>.delayed(_delay, greet);
/// greeting = Future<String>.delayed(_delay, greet);
/// }
/// }
///
/// @Component(
/// selector: 'async-time',
/// template: "<p>Time: {{ $pipe.date($pipe.async(time), 'mediumTime') }}</p>") //
/// selector: 'async-time',
/// template: "<p>Time: {{ $pipe.date($pipe.async(time), 'mediumTime') }}</p>",
/// )
/// class AsyncTimePipe {
/// static const _delay = const Duration(seconds: 1);
/// final Stream<DateTime> time =
/// new Stream.periodic(_delay, (_) => new DateTime.now());
/// static const _delay = Duration(seconds: 1);
/// final Stream<DateTime> time = Stream.periodic(_delay, (_) =>DateTime.now());
/// }
/// ```
///
@Pipe('async', pure: false)
class AsyncPipe implements OnDestroy {
Object? _latestValue;
Object? _subscription;
dynamic /* Stream | Future | EventEmitter */ _obj;
dynamic /* Stream | Future */ _obj;
dynamic _strategy;
final ChangeDetectorRef _ref;

Expand All @@ -95,7 +97,7 @@ class AsyncPipe implements OnDestroy {
}
}

dynamic transform(dynamic /* Stream | Future | EventEmitter */ obj) {
dynamic transform(dynamic /* Stream | Future */ obj) {
if (_obj == null) {
if (obj != null) {
_subscribe(obj);
Expand All @@ -107,14 +109,14 @@ class AsyncPipe implements OnDestroy {
return _latestValue;
}

void _subscribe(dynamic /* Stream | Future | EventEmitter */ obj) {
void _subscribe(dynamic /* Stream | Future */ obj) {
_obj = obj;
_strategy = _selectStrategy(obj);
_subscription = _strategy.createSubscription(
obj, (Object? value) => _updateLatestValue(obj, value));
}

dynamic _selectStrategy(dynamic /* Stream | Future | EventEmitter */ obj) {
dynamic _selectStrategy(dynamic /* Stream | Future */ obj) {
if (obj is Future<Object?>) {
return _promiseStrategy;
} else if (obj is Stream<Object?>) {
Expand Down
2 changes: 1 addition & 1 deletion ngdart/lib/src/common/pipes/common_pipes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'uppercase_pipe.dart' show UpperCasePipe;
/// This collection can be used to quickly enumerate all the built-in pipes in
/// the `pipes` property of the `@Component` annotation. For most applications
/// it's recommended to only reference the _exact_ pipes you use, however.
const commonPipes = [
const List<Type> commonPipes = <Type>[
AsyncPipe,
UpperCasePipe,
LowerCasePipe,
Expand Down
17 changes: 9 additions & 8 deletions ngdart/lib/src/common/pipes/date_pipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import 'invalid_pipe_argument_exception.dart';
/// in Chrome and Opera browsers.
///
/// ## Usage
///
/// $pipe.date(expression, [format])
///
/// ```dart
/// $pipe.date(expression, [format])
/// ```
/// where `expression` is a date object or a number (milliseconds since UTC
/// epoch) and `format` indicates which date/time components to include:
///
Expand Down Expand Up @@ -62,11 +62,12 @@ import 'invalid_pipe_argument_exception.dart';
///
/// Assuming `dateObj` is (year: 2015, month: 6, day: 15, hour: 21, minute: 43,
/// second: 11) in the _local_ time and locale is 'en-US':
///
/// {{ $pipe.date(dateObj) }} // output is 'Jun 15, 2015'
/// {{ $pipe.date(dateObj, 'medium') }} // output is 'Jun 15, 2015, 9:43:11 PM'
/// {{ $pipe.date(dateObj, 'shortTime') }} // output is '9:43 PM'
/// {{ $pipe.date(dateObj, 'mmss') }} // output is '43:11'
/// ```dart
/// {{ $pipe.date(dateObj) }} // output is 'Jun 15, 2015'
/// {{ $pipe.date(dateObj, 'medium') }} // output is 'Jun 15, 2015, 9:43:11 PM'
/// {{ $pipe.date(dateObj, 'shortTime') }} // output is '9:43 PM'
/// {{ $pipe.date(dateObj, 'mmss') }} // output is '43:11'
/// ```
@Pipe('date', pure: true)
class DatePipe {
static const Map<String, String> _aliases = {
Expand Down
41 changes: 21 additions & 20 deletions ngdart/lib/src/common/pipes/number_pipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ class _NumberPipe {
/// configurations are based on the active locale.
///
/// ### Usage
///
/// $pipe.number(expression, [digitInfo])
///
/// ```dart
/// $pipe.number(expression, [digitInfo])
/// ```
/// where `expression` is a number and `digitInfo` has the following format:
///
/// {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
///
/// ```dart
/// {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
/// ```
/// - minIntegerDigits is the minimum number of integer digits to use. Defaults to 1.
/// - minFractionDigits is the minimum number of digits after fraction. Defaults to 0.
/// - maxFractionDigits is the maximum number of digits after fraction. Defaults to 3.
Expand All @@ -81,9 +81,9 @@ class DecimalPipe extends _NumberPipe {
/// Formats a number as local percent.
///
/// ### Usage
///
/// $pipe.percent(expression, [digitInfo])
///
/// ```dart
/// $pipe.percent(expression, [digitInfo])
/// ```
/// For more information about `digitInfo` see [DecimalPipe]
@Pipe('percent')
class PercentPipe extends _NumberPipe {
Expand All @@ -100,9 +100,9 @@ class PercentPipe extends _NumberPipe {
/// Formats a number as local currency.
///
/// ### Usage
///
/// $pipe.currency(expression, [currencyCode, symbolDisplay, digitInfo])
///
/// ```dart
/// $pipe.currency(expression, [currencyCode, symbolDisplay, digitInfo])
/// ```
/// where `currencyCode` is the ISO 4217 currency code, such as "USD" for the
/// US dollar and "EUR" for the euro. `symbolDisplay` is a boolean indicating
/// whether to use the currency symbol (e.g. $) or the currency code (e.g. USD)
Expand All @@ -115,14 +115,15 @@ class CurrencyPipe extends _NumberPipe {
String currencyCode = 'USD',
bool symbolDisplay = false,
String? digits,
]) =>
_NumberPipe._format(
value,
_NumberFormatStyle.currency,
digits,
currencyCode,
symbolDisplay,
);
]) {
return _NumberPipe._format(
value,
_NumberFormatStyle.currency,
digits,
currencyCode,
symbolDisplay,
);
}

const CurrencyPipe();
}
Expand Down
Loading