Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!doctype html>
<html ng-app="myApp">
<head>
  <title>Parse Expression Example</title>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script>
</head>
<body>
  <div ng-controller="MyController">
    <input ng-model="expr"
            type="text"
            placeholder="Enter an expression" />
    <div>{{ parsedExpr }}</div>
  </div>
  </body>
</html>
 
    // open this example and type person.name into the test field
    angular.module('myApp', [])
    .controller('MyController',
    ['$scope', '$parse', function($scope, $parse) {
      $scope.person = {
        name: "Ari Lerner"
      };
      $scope.$watch('expr', function(newVal, oldVal, scope) {
        if (newVal !== oldVal) {
          // Let's set up our parseFun with the expression
          var parseFun = $parse(newVal);
          // Get the value of the parsed expression, set it on the scope for output
          scope.parsedExpr = parseFun(scope);
        }
      });
    }]);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
auserpro
0viewers