Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does const mean?

Tags:

angular

dart

I am using angular2dart and want to know, why do I have to pass keyword const on:

directives: const [HeroDetailComponent]

component properties.

like image 508
softshipper Avatar asked Sep 02 '26 04:09

softshipper


1 Answers

const means a compile-time constant. Been constant it can be optimized and instantiated only once.

const [HeroDetailComponent] means that the list is a compile time constant. Compile-time constants are mandatory when used as metadata (in your case directives is a named parameter of @Component() that is a metadata of your class).

like image 187
Alexandre Ardhuin Avatar answered Sep 03 '26 18:09

Alexandre Ardhuin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!