<div ng-app="myApp3" ng-controller="textController">
<p>
我的笔记
</p>
<p>
<textarea ng-model="message" cols="30" rows="10"></textarea>
</p>
<p>
<button ng-click="save()">保存</button> <button ng-click="reset()">清除</button>
</p>
<p>
剩余字数:<span ng-bind="left()">100</span>
</p>
</div>
var app = angular.module('myApp3', []);
app.controller('textController', function($scope){
$scope.message = '';
$scope.save = function(){
alert( $scope.message );
}
$scope.left = function(){
return 100 - $scope.message.length;
}
$scope.reset = function(){
$scope.message = '';
}
})