AngularJS Example:

by rossmartin

HTML

<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div ng-app>
  <div ng-controller="TodoCtrl">
    <input type="text" ng-model="input.authenticationCode">
    <br>
    <button class="button" ng-click="authenticate()">Authenticate</button>
    <br>
    <span>Auth info: {{input.authInfo}}</span>
    <br>
    <span>authenticationCode - {{input.authenticationCode}}</span>
  </div>
</div>

JavaScript

function TodoCtrl($scope) {
    $scope.input = {
        authenticationCode: 'TESTER',
        authInfo: ''
    };

    $scope.authenticate = function() {
        console.log('authInfo: ' + $scope.input.authInfo);
    };

    $scope.$watch('input.authenticationCode', function(newValue, oldValue) {
        console.log('newValue: ' + newValue);
        $scope.input.authInfo = newValue;
    });
}