Hi Guys I want to write a angular directive which encodes the input text to html.
So that critical characters are converted. For example ö -> ö
I have found this nice library, which I want to use.
My problem is I want to have this convertation only in my model. The user shouldn't see anything from this.
For now I have tried this way. But this doesn't do what I want. I'm new to angular and don't get comfortable with directives. Maybe you can help me.
angular.module('schwimmfestivalAngApp')
.directive('encodedInput', function () {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, ctrl, he) {
element.bind('onblur',
function () {
ctrl.$modelValue = he.encode(ctrl.$viewValue, {
'useNamedReferences': true
});
}
)
;
}
};
});