diff --git a/adev/src/content/tutorials/deferrable-views/steps/1-what-are-deferrable-views/README.md b/adev/src/content/tutorials/deferrable-views/steps/1-what-are-deferrable-views/README.md index 97abbd37b20..b7250213a41 100644 --- a/adev/src/content/tutorials/deferrable-views/steps/1-what-are-deferrable-views/README.md +++ b/adev/src/content/tutorials/deferrable-views/steps/1-what-are-deferrable-views/README.md @@ -12,24 +12,24 @@ In this activity, you'll learn how to use deferrable views to defer load a secti In your `app.ts`, wrap the `article-comments` component with a `@defer` block to defer load it. - +```angular-html @defer { } - +``` By default, `@defer` loads the `article-comments` component when the browser is idle. In your browser's developer console, you can see that the `article-comments-component` lazy chunk file is loaded separately (The specific file names may change from run to run): - +```markdown Initial chunk files | Names | Raw size -chunk-NNSQHFIE.js | - | 769.00 kB | +chunk-NNSQHFIE.js | - | 769.00 kB | main.js | main | 229.25 kB | Lazy chunk files | Names | Raw size chunk-T5UYXUSI.js | article-comments-component | 1.84 kB | - +``` diff --git a/adev/src/content/tutorials/deferrable-views/steps/2-loading-error-placeholder/README.md b/adev/src/content/tutorials/deferrable-views/steps/2-loading-error-placeholder/README.md index 9d32e42dc25..40d584c770b 100644 --- a/adev/src/content/tutorials/deferrable-views/steps/2-loading-error-placeholder/README.md +++ b/adev/src/content/tutorials/deferrable-views/steps/2-loading-error-placeholder/README.md @@ -39,25 +39,27 @@ In this activity, you'll learn how to use the `@loading`, `@error` and `@placeho In your `app.ts`, add a `@placeholder` block to the `@defer` block. - +```angular-html {highlight:[3,4,5]} @defer { } @placeholder {

Placeholder for comments

} -
+``` +
The `@placeholder` block accepts an optional parameter to specify the `minimum` amount of time that this placeholder should be shown. This `minimum` parameter is specified in time increments of milliseconds (ms) or seconds (s). This parameter exists to prevent fast flickering of placeholder content in the case that the deferred dependencies are fetched quickly. - +```angular-html {highlight:[3,4,5]} @defer { } @placeholder (minimum 1s) {

Placeholder for comments

} -
+``` +
@@ -72,7 +74,7 @@ Both parameters are specified in time increments of milliseconds (ms) or seconds Update `app.ts` to include a `@loading` block with a minimum parameter of `1s` as well as an after parameter with the value 500ms to the @loading block. - +```angular-html {highlight:[5,6,7]} @defer { } @placeholder (minimum 1s) { @@ -80,7 +82,7 @@ Update `app.ts` to include a `@loading` block with a minimum parameter of `1s` a } @loading (minimum 1s; after 500ms) {

Loading comments...

} -
+``` NOTE: this example uses two parameters, separated by the ; character. @@ -89,7 +91,7 @@ NOTE: this example uses two parameters, separated by the ; character. Finally, add an `@error` block to the `@defer` block. - +```angular-html {highlight:[7,8,9]} @defer { } @placeholder (minimum 1s) { @@ -99,7 +101,8 @@ Finally, add an `@error` block to the `@defer` block. } @error {

Failed to load comments

} -
+``` +
diff --git a/adev/src/content/tutorials/deferrable-views/steps/3-defer-triggers/README.md b/adev/src/content/tutorials/deferrable-views/steps/3-defer-triggers/README.md index 4308728f599..98ccd8c45a2 100644 --- a/adev/src/content/tutorials/deferrable-views/steps/3-defer-triggers/README.md +++ b/adev/src/content/tutorials/deferrable-views/steps/3-defer-triggers/README.md @@ -41,7 +41,7 @@ In this activity, you'll learn how to use triggers to specify the condition to l In your `app.ts`, add an `on hover` trigger to the `@defer` block. - +```angular-html {highlight:[1]} @defer (on hover) { } @placeholder (minimum 1s) { @@ -51,7 +51,7 @@ In your `app.ts`, add an `on hover` trigger to the `@defer` block. } @error {

Failed to load comments

} -
+``` Now, the page will not render the comments section until you hover its placeholder.
@@ -59,7 +59,7 @@ Now, the page will not render the comments section until you hover its placehold Next, update the template to include a button with the label "Show all comments". Include a template variable called `#showComments` with the button. - +```angular-html {highlight:[1]} @defer (on hover) { @@ -72,7 +72,7 @@ Next, update the template to include a button with the label "Show all comments" } @error {

Failed to load comments

} -
+``` NOTE: for more information on [template variables check the documentation](https://angular.dev/guide/templates/reference-variables#). @@ -81,7 +81,7 @@ NOTE: for more information on [template variables check the documentation](https Update the `@defer` block in the template to use the `on interaction` trigger. Provide the `showComments` template variable as the parameter to `interaction`. - +```angular-html {highlight:[3]} @defer (on hover; on interaction(showComments)) { @@ -94,7 +94,7 @@ Update the `@defer` block in the template to use the `on interaction` trigger. P } @error {

Failed to load comments

} -
+``` With these changes, the page will wait for one of the following conditions before rendering the comments section: diff --git a/adev/src/content/tutorials/learn-angular/steps/10-deferrable-views/README.md b/adev/src/content/tutorials/learn-angular/steps/10-deferrable-views/README.md index e80d301fc70..545c31b1bdc 100644 --- a/adev/src/content/tutorials/learn-angular/steps/10-deferrable-views/README.md +++ b/adev/src/content/tutorials/learn-angular/steps/10-deferrable-views/README.md @@ -32,13 +32,13 @@ The code above is an example of how to use a basic `@defer` block. By default `@ Add a `@placeholder` block to the `@defer` block. The `@placeholder` block is where you put html that will show before the deferred loading starts. The content in `@placeholder` blocks is eagerly loaded. - +```angular-html {highlight:[3,4,5]} @defer { } @placeholder {

Future comments

} -
+```
@@ -46,7 +46,7 @@ Add a `@placeholder` block to the `@defer` block. The `@placeholder` block is wh Add a `@loading` block to the `@defer` block. The `@loading` block is where you put html that will show _while_ the deferred content is actively being fetched, but hasn't finished yet. The content in `@loading` blocks is eagerly loaded. - +```angular-html {highlight:[5,6,7]} @defer { } @placeholder { @@ -54,7 +54,7 @@ Add a `@loading` block to the `@defer` block. The `@loading` block is where you } @loading {

Loading comments...

} -
+```
@@ -62,7 +62,7 @@ Add a `@loading` block to the `@defer` block. The `@loading` block is where you Both `@placeholder` and `@loading` sections have optional parameters to prevent flickering from occurring when loading happens quickly. `@placeholder` has `minimum` and `@loading` has `minimum` and `after`. Add a `minimum` duration to the `@loading` block so it will be rendered for at least 2 seconds. - +```angular-html {highlight:[5]} @defer { } @placeholder { @@ -70,7 +70,7 @@ Both `@placeholder` and `@loading` sections have optional parameters to prevent } @loading (minimum 2s) {

Loading comments...

} -
+```
@@ -78,11 +78,11 @@ Both `@placeholder` and `@loading` sections have optional parameters to prevent Deferrable views have a number of trigger options. Add a viewport trigger so the content will defer load once it enters the viewport. - +```angular-html {highlight:[1]} @defer (on viewport) { } - +``` @@ -90,7 +90,7 @@ Deferrable views have a number of trigger options. Add a viewport trigger so the A viewport trigger is best used when you're deferring content that's far enough down the page that it needs to be scrolled to see. So let's add some content to our blog post. You can either write your own, or you can copy the content below and put it inside the `
` element. - +```html {highlight:[1]}

Angular is my favorite framework, and this is why. Angular has the coolest deferrable view feature that makes defer loading content the easiest and most ergonomic it could possibly be. The Angular community is also filled with amazing contributors and experts that create excellent content. The community is welcoming and friendly, and it really is the best community out there.

I can't express enough how much I enjoy working with Angular. It offers the best developer experience I've ever had. I love that the Angular team puts their developers first and takes care to make us very happy. They genuinely want Angular to be the best framework it can be, and they're doing such an amazing job at it, too. This statement comes from my heart and is not at all copied and pasted. In fact, I think I'll say these exact same things again a few times.

@@ -99,7 +99,7 @@ A viewport trigger is best used when you're deferring content that's far enough

Angular is my favorite framework, and this is why. Angular has the coolest deferrable view feature that makes defer loading content the easiest and most ergonomic it could possibly be. The Angular community is also filled with amazing contributors and experts that create excellent content. The community is welcoming and friendly, and it really is the best community out there.

I can't express enough how much I enjoy working with Angular. It offers the best developer experience I've ever had. I love that the Angular team puts their developers first and takes care to make us very happy. They genuinely want Angular to be the best framework it can be, and they're doing such an amazing job at it, too. This statement comes from my heart and is not at all copied and pasted.

-
+``` Once you've added this code, now scroll down to see the deferred content load once you scroll it into the viewport. diff --git a/adev/src/content/tutorials/learn-angular/steps/11-optimizing-images/README.md b/adev/src/content/tutorials/learn-angular/steps/11-optimizing-images/README.md index d93a5b4b552..46ae450ac38 100644 --- a/adev/src/content/tutorials/learn-angular/steps/11-optimizing-images/README.md +++ b/adev/src/content/tutorials/learn-angular/steps/11-optimizing-images/README.md @@ -31,7 +31,7 @@ import { NgOptimizedImage } from '@angular/common'; To enable the `NgOptimizedImage` directive, swap out the `src` attribute for `ngSrc`. This applies for both static image sources (i.e., `src`) and dynamic image sources (i.e., `[src]`). - +```angular-ts {highlight:[[9],[13]]} import { NgOptimizedImage } from '@angular/common'; @Component({ @@ -48,7 +48,7 @@ template: ` ... `, imports: [NgOptimizedImage], }) - +``` diff --git a/adev/src/content/tutorials/learn-angular/steps/12-enable-routing/README.md b/adev/src/content/tutorials/learn-angular/steps/12-enable-routing/README.md index 064e0d71f74..6bb497aabd0 100644 --- a/adev/src/content/tutorials/learn-angular/steps/12-enable-routing/README.md +++ b/adev/src/content/tutorials/learn-angular/steps/12-enable-routing/README.md @@ -33,7 +33,7 @@ In `app.config.ts`, configure the app to Angular Router with the following steps 1. Import `routes` from the `./app.routes.ts`. 1. Call the `provideRouter` function with `routes` passed in as an argument in the `providers` array. - +```ts {highlight:[2,3,6]} import {ApplicationConfig} from '@angular/core'; import {provideRouter} from '@angular/router'; import {routes} from './app.routes'; @@ -41,7 +41,7 @@ import {routes} from './app.routes'; export const appConfig: ApplicationConfig = { providers: [provideRouter(routes)], }; - +``` @@ -51,12 +51,13 @@ Finally, to make sure your app is ready to use the Angular Router, you need to t Update the template for `App` by adding `` - +```angular-ts {highlight:[11]} import {RouterOutlet} from '@angular/router'; @Component({ ... -template: `