Inorder ng-model ng-change -, , . , contenteditable ( angular input, form ..), ng-model, keyup view render ng-. setViewValue ng-model , angular ng-change.
.directive('contenteditable', function() {
return {
require: 'ngModel',
restrict: 'A',
link: function(scope, elm, attr, ngModel) {
function updateViewValue() {
ngModel.$setViewValue(this.innerHTML);
}
elm.on('keyup', updateViewValue);
scope.$on('$destroy', function() {
elm.off('keyup', updateViewValue);
});
ngModel.$render = function(){
elm.html(ngModel.$viewValue);
}
}
}
});
:
<div class="form-control" type="search"
ng-model="seach" ng-change="searchChanged()"
contenteditable="true"></div>
angular.module('app', []).controller('ctrl', function($scope) {
$scope.seach = "Initial";
$scope.searchChanged = function() {
console.log('changed', $scope.seach);
}
}).directive('contenteditable', function() {
return {
require: 'ngModel',
restrict: 'A',
link: function(scope, elm, attr, ngModel) {
function updateViewValue() {
ngModel.$setViewValue(this.innerHTML);
}
elm.on('keyup', updateViewValue);
scope.$on('$destroy', function() {
elm.off('keyup', updateViewValue);
});
ngModel.$render = function() {
elm.html(ngModel.$viewValue);
}
}
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
Edit
<div class="form-control" type="search" ng-model="seach" ng-change="searchChanged()" contenteditable="true"></div>
{{seach}}
</div>
Hide result