Angular: Empty Fiddle

http://angularjs.org/

by Tahsis Claus

HTML

<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-app="myApp">
    <div ng-controller="MyCtrl">
        <input ng-model="test.test" ng-change="validateInput()" type="text">
    </div>
</div>

JavaScript

var myApp = angular.module('myApp', []);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

myApp.controller('MyCtrl', ['$scope', '$timeout', function ($scope, $timeout) {
    
    $scope.test = {};

    $scope.test.test = "http://";

    $scope.validateInput = function () {
        if($scope.test.test.indexOf("http://") != 0){
        $timeout(function() {
            $scope.test.test = "http://" + $scope.test.test;
        });
        }
    };

}]);

/*function MyCtrl($scope) {
    $scope.name = 'Superhero';
}*/