title: Populate AngularJS model with existing values
body: <p>I'm adding a mild amount of angularjs to my existing application.  I'm starting with utilizing controllers to manage my forms which are all submitted by ajax.  The forms are currently pulled into the page using jQuery's <code>$.load()</code> function and the form elements already have values.</p>
  
  <p>I'd like my models I've assigned into $scope to have these values available.  For example:</p>
  
  <pre><code>&lt;form&gt;
    &lt;input type="text" ng-model="user.firstName" value="Gregg" /&gt;
    &lt;input type="text" ng-model="user.lastName" value="Bolinger" /&gt;
    &lt;button ng-click="update(user)"&gt;Save&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And then in my main.js file I would have something like the following:</p>
  
  <pre><code>function UserCtrl($scope) {
    $scope.update = function(user) {
      // update the user
    };
  }
  </code></pre>
  
  <p>As is, my form input elements are blank because the ng-model is empty.  Is there a way to initialize my ng-model with the existing values in the form?</p>
  
  <p>BTW, I did read <a href="https://stackoverflow.com/questions/13769732/angular-js-init-ng-model-from-default-values">this SO Question</a> which is the same as mine, however, I'm hoping for a better answer than some window scoped global variable.</p>