Created
          March 21, 2015 19:47 
        
      - 
      
- 
        Save gecbla/a62c1ae476aa3fe4f35a to your computer and use it in GitHub Desktop. 
    JS Bin // source http://jsbin.com/xexopusoxe
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> | |
| <meta charset=utf-8 /> | |
| <title>JS Bin</title> | |
| </head> | |
| <body ng-app="myApp"> | |
| <div ng-controller="MyController"> | |
| <input ng-model="to" | |
| type="email" | |
| placeholder="Recipient" /> | |
| <textarea ng-model="emailBody"></textarea> | |
| <pre style="border: 1px solid; padding: 5px;">{{ previewText }}</pre> | |
| </div> | |
| <script id="jsbin-javascript"> | |
| angular.module('myApp', []) | |
| .controller('MyController', | |
| function($scope, $interpolate) { | |
| $scope.to = '[email protected]'; | |
| $scope.emailBody = 'Hello {{ to }},\n\nMy name is Ari too!'; | |
| // Set up a watch | |
| $scope.$watch(function (scope) { | |
| return scope.to; | |
| }, function(new_val, old_val) { | |
| alert(new_val+' '+old_val); | |
| if (new_val) { | |
| var template = $interpolate($scope.emailBody); | |
| $scope.previewText = template({to: $scope.to}); | |
| } | |
| }); | |
| }); | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">angular.module('myApp', []) | |
| .controller('MyController', | |
| function($scope, $interpolate) { | |
| $scope.to = '[email protected]'; | |
| $scope.emailBody = 'Hello {{ to }},\n\nMy name is Ari too!'; | |
| // Set up a watch | |
| $scope.$watch(function (scope) { | |
| return scope.to; | |
| }, function(new_val, old_val) { | |
| alert(new_val+' '+old_val); | |
| if (new_val) { | |
| var template = $interpolate($scope.emailBody); | |
| $scope.previewText = template({to: $scope.to}); | |
| } | |
| }); | |
| });</script></body> | |
| </html> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | angular.module('myApp', []) | |
| .controller('MyController', | |
| function($scope, $interpolate) { | |
| $scope.to = '[email protected]'; | |
| $scope.emailBody = 'Hello {{ to }},\n\nMy name is Ari too!'; | |
| // Set up a watch | |
| $scope.$watch(function (scope) { | |
| return scope.to; | |
| }, function(new_val, old_val) { | |
| alert(new_val+' '+old_val); | |
| if (new_val) { | |
| var template = $interpolate($scope.emailBody); | |
| $scope.previewText = template({to: $scope.to}); | |
| } | |
| }); | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment