@@ -15,19 +15,19 @@ app.directive('contenteditable',function(){
1515 }
1616 //一开始scope.userContent是空
1717 console . log ( ngModel . $isEmpty ( scope . userContent ) ) ;
18- element . html ( attrs . defaultText ) ;
1918 ngModel . $setViewValue ( attrs . defaultText ) ;
2019 //调用了$setViewValue以后就不为空了,但是如果设置了ngModelOptions,则没用.
2120 console . log ( ngModel . $isEmpty ( scope . userContent ) ) ;
2221 ngModel . $render = function ( ) {
23- element . html ( ngModel . $viewValue || attrs . defaultText )
22+ element . html ( ngModel . $viewValue || attrs . defaultText ) ;
2423 } ;
2524 element . bind ( 'focus' , function ( ) {
2625 if ( element . html ( ) == attrs . defaultText ) {
2726 element . html ( '' )
2827 }
2928 } ) ;
3029 element . bind ( 'focus blur keyup change' , function ( ) {
30+ console . log ( scope . userContent ) ; //userContent这个实际的值应该是和$modelValue一致的.
3131 ngModel . $setViewValue ( element . html ( ) ) ;
3232 console . log ( '$viewValue为:' + ngModel . $viewValue ) ;
3333 console . log ( '$modelValue为:' + ngModel . $modelValue ) ;
@@ -39,11 +39,6 @@ app.directive('contenteditable',function(){
3939 }
4040} ) ;
4141
42- /*
43- 调用$setViewValue并不会触发$render,但是userContent会被同步.
44- 当直接修改了userContent这个值,则$render会被调用
45- */
46-
4742
4843/*app.controller('Rollback',function($scope){
4944 $scope.resetWithRollback = function(e){
0 commit comments