AngularJS UI Binding

by Daniel Clasen

HTML

<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div ng-app>
  <div ng-controller="LikeExample">
    <p>{{like?'You like this.':'You don\'t like this.'}}</p>
    <form ng-submit="toggleLike()">
      <input type="submit" value="Click to toggle.">
    </form>
</div>

JavaScript

function LikeExample($scope) {
    
    $scope.like = false;  
    
    $scope.toggleLike = function() {
        $scope.like = !$scope.like;
    };
    
}