0

I have this array stateData.submenu :

    [
      {
        "template": "<span translate>myContacts</span>",
        "sref": "contact.list"
      },
      {
        "template": "<span translate>myProjects</span>",
        "sref": "project.list"
      },
      {
        "template": "<span translate>myRecommendations</span>
          <span class=\"badge\">{{ notificationBadge }}</span>",
        "sref": "recommendation.list"
      }
    ]

I would like to interpolate all template properties with the service $interpolate I can interpret a single property for example with :

this.notificationBadge = this.$interpolate(stateData.submenu[2].template)(this)

How can I loop and interpolate all the properties using ecmaScript 2015 or Lodash for example ?

Mouad Ennaciri
  • 1,217
  • 3
  • 15
  • 28
  • What exactly do you mean by "interpolate all the properties"? What result do you expect? – Stanislav Kvitash Nov 07 '17 at 17:50
  • @StanislavKvitash the result of `this.notificationBadge = this.$interpolate(stateData.submenu)(this)` to know that `submenu` is a array – Mouad Ennaciri Nov 07 '17 at 17:57
  • Why do you need this? What is the purpose? `$interpolate` compiles a string with markup into an interpolation function, it can't work with array. What template are you expecting as a result? – Stanislav Kvitash Nov 07 '17 at 18:04

0 Answers0