title: how to add a script value dynamically in html head tag in javascript
body: <p>I am new to javaScript and html.
  I am trying to create a script value dynamically and add to html head tag from java script and i am using angularjs also  as following..</p>
  
  <p>my script.js</p>
  
  <pre><code>$http.get(URL).success(function (response) {
               $scope.trailers = response;
        var js = document.createElement('script');
        js.setAttribute('type', 'text/javascript');
        js.value = "api_gallery = ["+trailers[0].youtubeId +", "+trailers[1].youtubeId +"];api_titles = ['video1', 'video2'];api_descriptions = ['description1', 'description2'];";
  
         document.getElementsByTagName('head')[0].appendChild(js);
  });
  </code></pre>
  
  <p>Actually the above code is for youtube videos popup.for that I have to assign the youtube urls to the above script.</p>
  
  <p>and my details json is </p>
  
  <pre><code>[{"youtubeId": "https://www.youtube.com/watch?v=_eZh4R_6WtA"},{"youtubeId": "https://www.youtube.com/watch?v=ynDAZ8-xcSE"}]
  </code></pre>
  
  <p>thanks in advance... </p>