Doubts with the prefix of the selector in Angular

3

The prefix of the selectors in Angular by default is 'app'. Most of the examples and tutorials I have seen do not follow the prefix rule. It is not a major problem because although the prefix is not used the application works, although I understand that it is not a good practice.

My doubt arises at the moment I create modules. Can I use a different prefix? I understand that the idea of making a module is to encapsulate a functionality, so it seems logical to me that it has a different prefix.

Edited so that it shows a code with what I refer to the selector prefix.

@Component({
   selector: 'app-animals',
   templateUrl: './animals.component.html',
   ...
})
    
asked by Quidi90 06.09.2017 в 11:15
source

1 answer

2

Using a prefix can help you recognize, when you are looking at or editing templates, the tags that are from your native html application or from some other library that you are using, but you can choose which one you want to use ( or not use any).

When you use angular CLI to generate new components, always use the prefix 'app-' by default, but this is configurable if you edit angular-cli.json and modify the value of "prefix" .

    
answered by 07.09.2017 в 11:16