title: interpolate string with variable name in angularjs
body: <p>How to interpolate value inside interpolate?</p>
  
  <p>I am using a file where I have written message string and using <code>{{ vm.variable }}</code>  but I am unable to display the string with variable value on HTML.  </p>
  
  <p><em>input string</em> ( in JS ): <code>"Welcome {{name}} to the World."</code>  </p>
  
  <p><em>desired output string</em> (in HTML ): <code>"Welcome John Smith to the world."</code> </p>
  
  <p>look my code below</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>(function() {
  
      'use strict';
  
      angular
          .module('app', [])
          .value('_MSG_', {
                  "signup": "Welcome {{name}} to the World.",
                  "login": "last login from {{location}}"
          }).controller('MessageController', function($scope, $parse, $interpolate, _MSG_){
              var vm = this;
              vm.name = "John Smith";
              vm.location = "India";
              vm.welcomeMessage = _MSG_.signup;
              //========trial 1 =======
              // vm.finalString = $interpolate(vm.welcomeMessage); 
              // nothing happens but
              //=====trial 2=====
              // set {{vm.name}} in _MSG_.signup and do below
              // vm.finalString = $parse(_MSG_).assign($scope, vm.name);
              // ERROR [$parse:syntax] Syntax Error: Token '{' is an unexpected token at column 9 of the expression [Weclome {{vm.name}}.] starting at [{{vm.name}}.].
          });
  })();</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html ng-app="app"&gt;
  &lt;head&gt; 
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body ng-controller="MessageController as vm "&gt;
      {{ vm.welcomeMessage }} ==&gt; Welcome John Smith to the world
  
  
      // trial 1
  
      {{ vm.finalString }}
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>