Variable inside router template

Hi,

I’m trying to get a value from global array inside router template.
${catNames['{{categories[0]}}']}

But Its returning “undefined” message. if i add this.
{{categories[0]}}

Then it returns id properly. e.g: 8

And when i add plain number inside variable.
${catNames['8']}

That works fine and return category name.

Any suggestion. what am i doing wrong?

Thanks

Can you show the full template example and where do you use it?