Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

288
Vistas
In Angular, why is the selector in component decorator called the "css selector"?

I come from a HTML CSS Javascript background and I just started learning Angular with their official tutorial "Tour of Heroes".

I noticed that the official tutorial and other Youtubers whose videos I have been watching, refer to the selector of the component as CSS Selector. I do not understand why CSS is being included in the term here.

As far as I have understood, selector of a component looks for a matching tag on the root/parent component and it is a html tag in a html page.

Unable to understand how CSS comes into the picture for the term to be a CSS Selector

@Component({
  selector: 'app-heroes', //This is what I am referring to.
  templateUrl: './heroes.component.html',
  styleUrls: ['./heroes.component.scss', './test.scss']
})
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

A selector in CSS defines a rule on how to match against the DOM, determining where / when a given style rule applies. In Angular, directive / component selectors use these very selectors, too, to define what elements they apply to. Element selectors (like "app-my-component") for components are what you'll see most of the time, but you're not limited to those.

For example, you could write a component with a selector of "a[href]" which matches any a element that also has an href attribute. In fact, you could even use a selector of "[href]", matching on any element with such an attribute. You could even use a selector like ":not([href])" to apply your directive on any element which does not have such an attribute.

In practice this can be quite useful, especially for directives. In fact, if you look at the source code of Angular's RouterLink directive, you'll find that it is actually implemented as two separate directives, one with a selector of a[routerLink] and one with a selector of :not(a)[routerLink].

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda