Skip to content

Angular 03: templates and binding - #34

Merged
gpbsumido merged 6 commits into
ps/ng-02-componentsfrom
ps/ng-03-templates
Nov 21, 2026
Merged

gpbsumido merged 6 commits into
ps/ng-02-componentsfrom
ps/ng-03-templates

Conversation

@gpbsumido

@gpbsumido gpbsumido commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Third lesson in my Angular guide. Writing it turned up two real keyboard bugs and a date-formatting trap, and all three are fixed here.

What shipped

Fix: ⌃⌥Space never opened Spotlight. App.onKeydown called shortcuts.handleKeydown(event) twice per keydown.

  • Toggles flipped and flipped back, and ⌃⌥Tab skipped a window.
  • It's now bound once via host: { '(document:keydown)': … } instead of @HostListener.

Fix: ⌘Space was swallowed. A leftover preventDefault() that the 1.3.4 remap meant to remove is gone. A spec pins it.

Readable dates. Cards and the reader show "Jun 15, 2026" in a <time datetime>, formatted in UTC so a bare YYYY-MM-DD doesn't shift a day west of UTC. The detail is in the bundle section below.

Reading time. A pure readingTime pipe on prose thoughts.

Lesson 03: templates and binding (/thoughts/angular-03-templates)

  • Covers the material at three levels (simple, intermediate, expert), then pitfalls and interview Q&A.
  • Two live demos: property vs attribute binding on a real input, and @for/@empty/@let/@switch on a removable tag list.

Version and changelog. 1.4.2, with a matching changelog entry.

The bundle detour

DatePipe was the first version, and the production build put the initial bundle up 13 kB (375.71 → 389.07 kB):

  • @angular/common is one module the app already loads eagerly.
  • So DatePipe's locale code landed in the initial chunk, even though both thought views are lazy.

The fix is a five-line utcDate pipe over Intl.DateTimeFormat. It renders the same output and brings the initial bundle back to 377.25 kB. That story is now an expert callout in the lesson.

Commits

  1. Add failing specs for the double keydown, thought dates and lesson 03
  2. Add a failing spec for formatted dates on thought cards
  3. Handle each desktop keydown once and stop swallowing Cmd+Space
  4. Format thought dates in UTC and show reading time
  5. Write lesson 03 with property-vs-attribute and control-flow demos
  6. Bump to 1.4.2 with the lesson 03 changelog entry

Verification

  • Before the fix, the new specs failed for the right reasons: spotlightOpen stayed false after one ⌃⌥Space, ⌘Space was defaultPrevented, and dates rendered as 2026-06-15.
  • ng test: 47 files, 341 tests, exit 0. Lint and both tsc --noEmit configs are clean.
  • Production build: no budget warnings. Prerendered /thoughts/signals shows Jun 15, 2026 · 1 min read.

TO-DOs for this PR

  • Before/after screenshots of the thoughts list and a thought (dates, reading time) plus the lesson 03 page, light and dark. Chromium couldn't launch in the environment I built this in.

@gpbsumido
gpbsumido marked this pull request as ready for review November 21, 2026 14:53
@gpbsumido
gpbsumido added this pull request to stack #46 November 21, 2026 17:00
@gpbsumido
gpbsumido merged commit 530c68f into develop Nov 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant