Angular: Empty Fiddle

http://angularjs.org/

by Nicolas PUJOL

HTML

<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
  Toggle:
  <input type="checkbox" ng-model="currentAdJSON.enableCta" ng-change="enableCtaChange()">
  <br>
  <input type="text" ng-model="currentAdJSON.callToAction.text" ng-disabled="!currentAdJSON.enableCta">
</div>

JavaScript

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

function MyCtrl($scope) {
  $scope.currentAdJSON = {
    enableCta: true,
    callToAction: {
      text: 'Buy Now'
    }
  };
  $scope.enableCtaChange = function() {
    if (!$scope.currentAdJSON.enableCta) {
      $scope.currentAdJSON.callToAction.text = '';
    }
  };
}