AngularJS Example

by sunnycpp

HTML

<div ng-app="">
  <form name="myForm" ng-controller="Ctrl" ng-submit="submitForm()">
    userType: <input type="email" name="input" ng-model="userType" required>    
    <tt>userType = {{userType}}</tt><br>    
   </form>
</div>

CSS

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

JavaScript

function Ctrl($scope, $window) {
  $scope.userType = 'guest';
    $scope.submitForm = function() {
        $window.alert("In submitForm");
    }
}