title: AngularJS - Dynamic ngModel with "key.key.key..value"
body: <p>I know this looks like a duplicate question, but I wasn't able to find anything pertaining this?</p>
  
  <p>I have a variable such as <code>"settings.page.header.title"</code></p>
  
  <p>I would like to set the <code>ngModel</code> of an input to the above dynamically, as it will change.</p>
  
  <hr>
  
  <p>I've tried the following without success:</p>
  
  <p>1)</p>
  
  <pre><code>$scope.getDynamicModel = function(str) {
    var levels = str.split(".");
    var model = $scope;
    for (var i = 0, i &lt; levels.length; i++) {
      var level = levels[i];
      model = model[level];
    }
    return model;
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>&lt;input ng-model="getDynamicModel('settings.page.header.title')"&gt;
  </code></pre>
  
  <p>2) </p>
  
  <pre><code>&lt;input ng-model="{{ 'settings.page.header.title' }}"&gt;
  </code></pre>
  
  <hr>
  
  <p>Any ideas?</p>