AngularJS Example:

HTML

<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div ng-app='app'>
  <div ng-controller="MainCtrl">
      <input type="button" method="POST" ng-click="fillForm()" value="Populate Form Input" />
    <form role="form" ng-submit="submitForm()" form-auto-fill-fix>
        <input type="text" id="name" name="name" ng-model="formData.name">
        <input type="submit" value="Submit" />
    </form>
  </div>
</div>

JavaScript

var app = angular.module('app', [])
    
    app.directive('formAutoFillFix', function() {
  return function(scope, elem, attrs) {
    // Fixes Chrome bug: https://groups.google.com/forum/#!topic/angular/6NlucSskQjY
    elem.prop('method', 'POST');

    // Fix autofill issues where Angular doesn't know about autofilled inputs
    if(attrs.ngSubmit) {
      setTimeout(function() {
        elem.unbind('submit').bind('submit', function(e) {
          e.preventDefault();
 elem.find('input').triggerHandler('input').triggerHandler('change');
          scope.$apply(attrs.ngSubmit);
        });
      }, 0);
    }
  };
});

function MainCtrl($scope) {
  $scope.formData = {};
    
    $scope.fillForm = function(){
    	document.getElementById('name').value = "Paul Smith";
    }
    
    $scope.submitForm = function(ele){
        
    	console.log($scope.formData);
    
    }
}