AngularJS Example

HTML

<div ng-app="">
  <div ng-controller="Ctrl">
    Enter number: <input type="text" ng-model="number"><br>
    Hello <span ng-bind="hi"></span>
  </div>
</div>

CSS

</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ --> 
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script>
<style>
​.ng-invalid { border: 1px solid red; }​

JavaScript

function Ctrl($scope) {
  $scope.number = 4;
    
    $scope.$watch('number', function(newValue, oldValue) {
        var x = newValue;
        $scope.hi = "";
        while (x--) {
            $scope.hi += "Hi! ";
        }
    });
}