<html ng-app="customControl">
<script src="js/angular.js"></script>
<script src="js/jquery.js"></script>
<script>
angular.module('customControl', []).
directive('contenteditable', function() {
return {
restrict: 'A',
require: '?ngModel',
link: function(scope, element, attrs, ngModel) {
if(!ngModel) return;
ngModel.$render = function() {
element.html(ngModel.$viewValue || '');
};
element.on('blur keyup change', function() {
scope.$apply(read);
});
read(); // initialize
function read() {
var html = element.html();
if( attrs.stripBr && html == '<br>' ) {
html = '';
}
ngModel.$setViewValue(html);
}
}
};
});
</script>
<body>
<input type="number" ng-model="val" />
<input type="number" ng-model="val1" />
<span contenteditable ng-model="userContent">{{val+val1}}</span>
<!-- I want to show sum here -->
{{userContent}}
</body>
</html>}
Hi I want to bind span value to ng-model so that I can access or send value to database.if possible also assign span value to input filed.can any one tell me how to do this.Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire