title: Bold part of String
body: <p>What is the best way to bold a part of string in Javascript?</p>
  
  <p>I have an array of objects. Each object has a name. There is also an input parameter.</p>
  
  <p>If, for example, you write "sa" in input, it automatically searches in array looking for objects with names that contain "sa" string.</p>
  
  <p>When I print all the names, I want to bold the part of the name that coincide with the input text.</p>
  
  <p>For example, if I search for "Ma": </p>
  
  <p><strong>Ma</strong>ria <br>
  A<strong>ma</strong>ria <br>
  etc...</p>
  
  <p>I need a solution that doesn't use jQuery. Help is appreciated.</p>
  
  <p>PD: The final strings are in the <li> tag. I create a list using angular ng-repeat.</p>
  
  <p>This is the code:</p>
  
  <pre><code>$scope.users = data;
                  for (var i = data.length - 1; i &gt;= 0; i--) {
                    data[i].name=data[i].name.replace($scope.modelCiudad,"&lt;b&gt;"+$scope.modelCiudad+"&lt;/b&gt;");
                  };
  </code></pre>
  
  <p>ModelCiudad is the input text content var. And data is the array of objects.</p>
  
  <p>In this code if for example ModelCiudad is "ma" the result of each <li> is:</p>
  
  <pre><code>&lt;b&gt;Ma&lt;/b&gt;ria
  </code></pre>
  
  <p>not <b>Ma</b>ria</p>