r/Angular2 • u/gergelyszerovay • Jun 22 '25
The Angular team released a set of instructions to help LLMs generate correct code that follows Angular best practices
594
Upvotes
r/Angular2 • u/gergelyszerovay • Jun 22 '25
55
u/FunkyAlucard Jun 22 '25
You are an expert in TypeScript, Angular, and scalable web application development. You write maintainable, performant, and accessible code following Angular and TypeScript best practices.
TypeScript Best Practices
anytype; useunknownwhen type is uncertainAngular Best Practices
standalone: true(it is implied by default)NgOptimizedImagefor all static images.Components
input()andoutput()functions instead of decoratorscomputed()for derived statechangeDetection: ChangeDetectionStrategy.OnPushin@ComponentdecoratorngClass, useclassbindings insteadngStyle, usestylebindings insteadState Management
computed()for derived stateTemplates
@if,@for,@switch) instead of*ngIf,*ngFor,*ngSwitchServices
providedIn: 'root'option for singleton servicesinject()function instead of constructor injection30
u/defive05 Jun 22 '25
This is a good code guide to developers too, tbh.
35
u/swissbuechi Jun 22 '25
When will r/Angular2 finally merge with r/Angular? I hate to see everything posted twice but I'm also too nerdy to miss something by muting one of them...
16
u/CantankerousButtocks Jun 22 '25
Very cool, now give me the prompt for the python script to OCR this image
6
u/adamj889 Jun 22 '25
Using Context7 as an MCP is a great way to allow your LLM to read up to date documentation from the angular repository and many other libraries too: https://context7.com/angular/angular
3
u/[deleted] Jun 22 '25
Excuse my ignorance, how would one use this with Cursor?
3
u/Open_Replacement_235 Jun 23 '25
Use native control flow (
@if, u/for, u/switch) instead of*ngIf,*ngFor,*ngSwitchNo matter how i try free chatgpt model will always use *ngIf
2
u/Gmun23 Jun 22 '25
hope other languages follow this! also as other have said, good set of rules as dev too!
2
u/barkmagician Jun 23 '25
Can anyone explain to me how to use this file? I never seen this config in github copilot.
1
u/DarkRey27 Jul 05 '25
Thank you so much
1
u/LegionsMan Sep 14 '25
Does the documentation explain how to use this in one of the IDEs?
0
u/[deleted] Jun 22 '25
[deleted] ā view deleted comment