This commit replaces the old and slow `ReflectiveInjector` that was
deprecated in v5 with the new `Injector`. Note: This change was only
done in the spec files inside the `aio` folder.
While changing this, it was not possible to directly use `Injector.get`
to get the correct typing for the mocked classes. For example:
```typescript
locationService = injector.get<TestLocationService>(LocationService);
```
Fails with:
> Argument of type 'typeof LocationService' is not assignable to parameter
of type 'Type<TestLocationService> | InjectionToken<TestLocationService> |
AbstractType<TestLocationService>'.
Type 'typeof LocationService' is not assignable to type 'Type<TestLocationService>'.
Property 'searchResult' is missing in type 'LocationService' but required in type
'TestLocationService'.
Therefore, it was necessary to first convert to `unknown` and then to
`TestLocationService`.
```typescript
locationService = injector.get(LocationService) as unknown as TestLocationService;
```
PR Close#38408
The compiler does not currently report errors when there's an `@Input()`
for a `private`, `protected`, or `readonly` directive/component class member.
This change adds an option to enable reporting errors when a template
attempts to bind to one of these restricted input fields.
PR Close#38249
The order of asset- and data-groups in `ngsw-config.json` affects how a
request is handled by the ServiceWorker. Previously, this was not
clearly documented.
This commit describes how the order of asset-/data-groups affects
request handling.
Closes#21189
PR Close#38364
Previously, the [processCliCommands][1] dgeni processor, which is used
to generate the docs pages for the CLI commands, expected the CLI
commands overview page (with a URL of `cli`) to exist as a child of a
top-level navigation section (`CLI Commands`). If one tried to move the
`CLI Commands` section inside another section, `processCliCommnads`
would fail to find it and thus fail to generate the CLI commands docs.
This problem came up in #38353.
This commit updates the `processCliCommands` processor to be able to
find it regardless of the position of the `CLI Commands` section inside
the navigation doc.
[1]:
dca4443a8e/aio/tools/transforms/cli-docs-package/processors/processCliCommands.js (L7-L9)
PR Close#38365
PR #36601 introduces icons on all links if the link contains
https:// or http:// but there were some internal links left
which contained https://angular.io. Removed https://angular.io
from all these links.
PR Close#38360
Some specialised browsers that do not support scroll restoration
(e.g. some web crawlers) do not allow `scrollRestoration` to be
writable.
We already sniff the browser to see if it has the `window.scrollTo`
method, so now we also check whether `window.history.scrollRestoration`
is writable too.
Fixes#30629
PR Close#30630
This commit updates the `tslint.json` configuration file, that is used
to lint the docs examples, to match the one generated for new Angular
CLI apps. There are some minimal differences (marked with `TODO`
comments) for things, such as component selector prefix, that would
require extensive and/or difficult to validate changes in guides.
This commit also includes the final adjustments to make the docs
examples code compatible with the new tslint rules. (The bulk of the
work has been done in previous commits.)
PR Close#38143
This commit updates the docs examples to be compatible with the
following Angular-specific tslint rules:
- `component-selector`
- `directive-selector`
- `no-conflicting-lifecycle`
- `no-host-metadata-property`
- `no-input-rename`
- `no-output-native`
- `no-output-rename`
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the
`prefer-const` tslint rule.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the
`variable-name` tslint rule without requiring the
`allow-leading-underscore` and `allow-trailing-underscore` options.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the
`no-shadowed-variable` and `variable-name` tslint rules.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the
`member-ordering` tslint rule.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the
`no-angle-bracket-type-assertion` tslint rule.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the
`no-string-literal`, `object-literal-key-quotes` and
`object-literal-shorthand` tslint rules.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the
`only-arrow-functions` tslint rule.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the
`jsdoc-format` tslint rule.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the
`semicolon` tslint rule.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the `align`,
`space-before-function-paren` and `typedef-whitespace` tslint rules.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
This commit updates the docs examples to be compatible with the
`import-spacing` tslint rule.
This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.
PR Close#38143
The `03-*` code style rule have been removed from the style guide in
be0bc799f3.
This commit removes the corresponding files and related unused code from
the`styleguide` example project.
PR Close#38143
The documentation is not clear on how the base href and APP_BASE_HREF are used. This commit
should help clarify more complicated use-cases beyond the most common one of just a '/'
PR Close#38123
Prior to this commit, SVG icons were all loaded in the constructor
of the `CustomIconRegistry`. This commit avoids that, and loads SVG
icons on demand.
PR Close#38268
This commit simplifies the creation of the temporary, hidden
`<textarea>` element used by `CopierService` by switching from absolute
to fixed positioning and not requiring page's scroll offset.
It also makes the following minor improvements:
- Make the element invisible (via `opacity: 0`).
- Instruct screen-readers to ignore the element (via
`aria-hidden: true`).
NOTE: These improvements are based on Angular CDK's [PendingCopy][1]
class and the changes proposed in PR angular/components#20073.
[1]: https://github.com/angular/components/blob/89b5fa89d1437c3054c5/src/cdk/clipboard/pending-copy.ts
PR Close#38244
The `CopierService` is used for copying text to the user's clipboard. It
is, for example, used in `CodeComponent` to copy example code snippets.
This is implemented by creating a temporary, hidden `<textarea>`
elements, setting its value to the text that needs to be copied,
executing the `copy` command and finally removing the element from the
DOM.
Previously, as a result of `CopierService`'s implementation, the focused
element would lose focus, while the temporary `<textarea>` element would
implicitly gain focus when selecting its contents. This had an even
worse side-effect on IE11, which seems to scroll to the bottom of the
containing element (here `<body>`) when the focused element is removed.
This commit fixes these issues by keeping track of the previously
focused element and restoring its focus after the copy operation.
NOTE: This fix is inspired by Angular CDK's [PendingCopy][1] class.
[1]: https://github.com/angular/components/blob/89b5fa89d1437c3054c5/src/cdk/clipboard/pending-copy.tsFixes#37796
PR Close#38244
This commit improves the code readability of the `CopierService` by:
- Adding/Improving JSDoc comments for methods.
- Avoiding unnecessary instance-wide properties.
- Fixing indentation to be consistent (at two spaces).
- Clearly separating the logic for creating and populating a
`<textarea>` from the logic for selecting and copying its contents.
PR Close#38244
Project DOCS-736 to rewrite headings to focus on user tasks,
verify that the content is up-to-date and complete, and
add relevant links to other NgModule topics to improve readability.
Also addresses one of many issues in GitHub issue 21531.
PR Close#38206
Project DOCS-734 to rewrite headings to focus on user tasks,
verify that the content is up-to-date and complete, and
add relevant links to other NgModule topics to improve readability.
Also addresses one of many issues in GitHub issue 21531.
PR Close#38148
This commit clarifies some of the language regarding pipes in the pipes guide.
This commit also specifies the term transforming rather than formatting.
PR Close#37950
Previously, `ExampleZipper` (the tool used for creating ZIP archives
from our docs examples) used the `PackageJsonCustomizer` to generate
`package.json` files for each example type. This had the following
drawbacks:
- The generated files had to be kept up-to-date with the corresponding
boilerplate files in `aio/tools/examples/shared/boilerplate/` and
there was no easy way to find out when the files got out-of-sync.
- The `PackageJsonCustomizer` logic was non-trivial and difficult to
reason about.
- The same information was duplicated in the boilerplate files and the
customizer configuration files.
This setup was useful when we used a single `package.json` file for all
docs examples. Now, however, each example type can have its own
boilerplate `package.json` file, including scripts and dependencies
relevant to the example type. Therefore, it is no longer necessary to
generate `package.json` files for ZIP archives.
This commit eliminates the drawbacks mentioned above and simplifies the
`ExampleZipper` tool by removing `PackageJsonCustomizer` and re-using
the boilerplate `package.json` files for ZIP archives.
The changes in this commit also fix some ZIP archives that were
previously broken (for example due to missing dependencies).
PR Close#38192