angualrJs中$interpolate的运用

来源:互联网 发布:数据统计图表分析 编辑:程序博客网 时间:2024/06/10 17:55

html部分:

<input type="email" ng-model="to" placeholder="请输入正确邮箱!"><textarea ng-model="emailBody"></textarea><pre>{{previewText}}</pre>

   javascript部分:

    

$scope.$watch('emailBody',function(body){    if(body){        var template = $interpolate(body);        $scope.previewText = template({to:$scope.to});    }})
截图: