@oguzhan18/angular-services

ALWAYS use when working with Angular Services, @Injectable, dependency injection, or business logic services.

View in AI SkillSafe app
Scanned · no findings
0 downloads
0 stars
0 demos
SKILL.md
nameangular-services
descriptionALWAYS use when working with Angular Services, @Injectable, dependency injection, or business logic services.

Angular Services

Version: Angular 21 (2025) Tags: Services, @Injectable, DI

References: Services Guide@Injectable API

Best Practices

  • Create service with providedIn
@Injectable({ providedIn: 'root' })
export class DataService {
  getData() {
    return this.http.get('/api/data');
  }
}
  • Use inject() function
@Injectable({ providedIn: 'root' })
export class UserService {
  private http = inject(HttpClient);
  
  getUsers() {
    return this.http.get<User[]>('/api/users');
  }
}
  • Use factory providers
@Injectable({
  providedIn: 'root',
  useFactory: () => new LoggerService(environment.production)
})
export class LoggerService {
  constructor(private isProduction: boolean) {}
}
  • Use providedIn: 'any' for lazy services
@Injectable({ providedIn: 'any' })
export class LazyService {}
  • Use service in component
@Component({})
export class MyComponent {
  private dataService = inject(DataService);
  
  data$ = this.dataService.getData();
}
  • Use multiple services
@Component({})
export class MyComponent {
  private auth = inject(AuthService);
  private http = inject(HttpClient);
  private router = inject(Router);
}
  • Use service for shared state
@Injectable({ providedIn: 'root' })
export class CartService {
  private items = signal<Item[]>([]);
  
  cartItems = this.items.asReadonly();
  
  addItem(item: Item) {
    this.items.update(items => [...items, item]);
  }
}

Embed badges

Add these to your README to show the skill's verification status.

SkillSafe verified badge
Verified badge
[![SkillSafe verified badge](https://api.skillsafe.ai/v1/badge/@oguzhan18/angular-services/verified)](https://skillsafe.ai/skill/@oguzhan18/angular-services/)
Installs badge
Installs badge
[![Installs badge](https://api.skillsafe.ai/v1/badge/@oguzhan18/angular-services/installs)](https://skillsafe.ai/skill/@oguzhan18/angular-services/)
Scan badge
Scan badge
[![Scan badge](https://api.skillsafe.ai/v1/badge/@oguzhan18/angular-services/scan)](https://skillsafe.ai/skill/@oguzhan18/angular-services/)
Eval pass rate badge
Eval pass rate
[![Eval pass rate badge](https://api.skillsafe.ai/v1/badge/@oguzhan18/angular-services/eval)](https://skillsafe.ai/skill/@oguzhan18/angular-services/)