侃侃无极
感觉你这个问题还是做成指令比较好,下面就是我的基本实现吧。htmlvarapp=angular.module('app',[]);app.directive('myTextarea',function(){return{require:'ngModel',link:function(scope,ele,attrs,modelController){vartext=attrs.myTextarea;varplaceholder=attrs.placeholder;varalltext=text+''+placeholder;ele.attr('placeholder',alltext);ele.on('focus',function(){if(!modelController.$modelValue){setVal(text);}});ele.on('blur',function(){if(modelController.$modelValue===text){setVal('');}});functionsetVal(v){modelController.$setViewValue(v);modelController.$render();}}}});app.controller('main',['$scope',function($scope){$scope.log=function(){console.log($scope.myText)}}]);基本思路就是通过model的controller来操控。