简体   繁体   中英

Angular2 - Variable variables

Short version:

How to use $$a like in PHP but in angular2?

Long version:

I have 2 const variables const foo = 'string' and const bar = 'string2'

And 1 variable foo2 = 'foo'

Would it be possible to call something like this.{{foo2}} with a result of 'string' ?

I know it's possible in PHP with $$a .

Simply use brackets notation:

{{ this[foo2] }}

Example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM