title: Javascript/Angular- How to do string interpolation inside a variable or a class method?
body: <p>I dont know if thats possible or not, but here is my ideia: </p>
  
  <p>I have a class with methods and i want to present the method in a h1 Html component that matches the selected string. </p>
  
  <p>Basically, i have a class of Pokemons, that each method is a pokemon, and i want to switch methods when my user select one type of pokemon. </p>
  
  <p>Here is the code:</p>
  
  <p>The service class (data) : </p>
  
  <pre><code>import { Injectable } from '@angular/core';
  
  @Injectable({
    providedIn: 'root'
  })
  export class GenIService {
  
    swampert = {
      hp: 138,
      atk: 121,
      def: 110.63,
      type: ' Water  Ground',
  
     };
  }
  
  </code></pre>
  
  <p>The main page : </p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import {GenIService} from "../Pokemons/gen-i.service";
  
  
  
  @Component({
    selector: 'app-home',
    templateUrl: 'home.page.html',
    styleUrls: ['home.page.scss'],
  })
  
  
  export class HomePage implements OnInit {
  
    genOne = [];
  
    button1clicked= false;
    button2clicked= false;
  
    pokemon1Selected = '';
    pokemon2Selected = '';
  
    constructor(private gen1: GenIService ) {}
  
    ngOnInit(): void {
      console.log(this.gen1.swampert.hp);
  
    }
  
    buttonOneSelected() {
      this.button1clicked= true;
      this.button2clicked=false;
    }
  
    buttonTwoSelected() {
      this.button1clicked= false;
      this.button2clicked=true;
    }
  
    pokemon1SeletectedSwampert() {
      this.pokemon1Selected = "Swampert";
  
    }
  
    pokemon2SeletectedVenusaur(){
      this.pokemon2Selected = 'Venusaur';
    }
  </code></pre>
  
  <p>The Html code:</p>
  
  <pre><code>&lt;ion-item&gt;
           &lt;ion-label&gt;Name: {{}}&lt;/ion-label&gt;
           &lt;ion-label&gt;HP: {{this.gen1.{pokemon1Selected}.hp}}&lt;/ion-label&gt;
           &lt;ion-label&gt;ATK: {{}}&lt;/ion-label&gt;
           &lt;ion-label&gt;DEF: {{}}&lt;/ion-label&gt;
           &lt;ion-label&gt;Type: {{}}&lt;/ion-label&gt;
  
      &lt;/ion-item&gt;
  </code></pre>
  
  <p>So, in the Html code i am tring to have this variable = this.gen1.swampert.hp, but switch the pokemon name with the variable of pokemon1Selected, that in this case is equal to "Swampert".</p>
  
  <p>How can i do that?</p>