ngModelがコントローラーからの初期値を設定しないのはなぜですか?
例: http: //plnkr.co/edit/sGFv4zpVtvpsmUx1c9F3
angular.module('customControl', [])
.directive('contenteditable', function() {
return {
restrict: 'A', // only activate on element attribute
require: '?ngModel', // get a hold of NgModelController
link: function(scope, element, attrs, ngModel) {
if(!ngModel) return; // do nothing if no ng-model
// Specify how UI should be updated
ngModel.$render = function() {
element.html(ngModel.$viewValue || '');
};
}
};
});
function TestCtrl($scope) {
$scope.userContent = 'It Works!!!!';
}