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 ?

3
  • What exactly do you mean by "interpolate all the properties"? What result do you expect? Commented Nov 7, 2017 at 17:50
  • @StanislavKvitash the result of this.notificationBadge = this.$interpolate(stateData.submenu)(this) to know that submenu is a array Commented Nov 7, 2017 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? Commented Nov 7, 2017 at 18:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.