watch进行监控, parse 手动解析
<!DOCTYPE html>
<html ng-app='myApp'>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
{{1}}
<div ng-controller='myController'>
<input type="text" ng-model='expr' placeholder="请输入值">
<h2>解析值{{parsedValue}}</h2>
</div>
</body>
</html>
var app = angular.module('myApp',[]);
app.controller('myController',['$scope','$parse',function($scope,$parse){
$scope.$watch('expr',function(oldVal,newVal,scope){
if(oldVal !== newVal){
var parseFun = $parse('expr');
$scope.parsedValue = parseFun(scope);
}
});
}]);