title: Accessing pre-filled input fields in controllers
body: <p>What is the best way to access pre-filled input fields values in angularjs? For example, how can I access the value of variable1 (which is pre-filled on pageload) within controller scope? I am using ng-model directive on the hidden input field and using $scope.formData.variable1 to access in the controller but with no luck. I tried searching in the web for similar issue, but most of the examples were related to accessing form field on submit or click. <a href="http://plnkr.co/edit/r7WbSKYhpqvl0jRHIeeY?p=preview" rel="nofollow">Here</a> is link to plnkr</p>
  
  <pre><code>&lt;body ng-controller="MainController"&gt;
  &lt;h1&gt;{{message}}&lt;/h1&gt;
  &lt;form name="formData"&gt;
  
    &lt;input type="hidden" name="variable1" ng-model="formdata.variable1" value="abc" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p>AngularJs Code:</p>
  
  <pre><code>(function() {
  
    var app = angular.module("testapp", []);
  
    var MainController = function($scope) {
      console.log($scope.formData.variable1);
  
      $scope.message = "Hello, Angular!";
  
  
    };
  
    app.controller("MainController", ["$scope", MainController]);
  
  }());
  </code></pre>