0

This is really basic, but I'm drawing a blank. I'm using ngModel to two-way data-bind to a variable from an input, but I want the value to be transformed on keypress the Angular 2 way. I have pipe that I'm using in another location for the same variable that has the replacement I need. The pipe just converts a title into a string usable as a URL routing slug. I'm not worried about that part. The problem is that pipes don't work with ngModel (as far as I can tell), so I have to do something else, and I can't remember what this is called.

When the user enters invalid characters (numbers, special characters) into a field, I need those characters cleared from both the field and the variable, immediately, so the user will never see them. What is this called, and how do I do it? I already used (keypress), but that didn't clear the characters immediately.

5
  • Can you post code that you've already written? Commented Mar 31, 2017 at 19:10
  • 1
    Use should be using directives to achieve these. You can refer to this answer it also has a demo. Let me know if you need some more help. Note: if needed you can use keydown event in the directive Commented Mar 31, 2017 at 19:19
  • My question is a duplicate of this question: stackoverflow.com/questions/37603705/… Commented Mar 31, 2017 at 20:13
  • @BBaysinger so did you fix your issue or need more help Commented Apr 1, 2017 at 2:59
  • 1
    Possible duplicate of Angular 2 Input Custom Pipe Commented Apr 19, 2018 at 13:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.