born2net / Angular-kitchen-sink

:rocket: Angular - learn by example
http://ng.javascriptninja.io
755 stars 146 forks source link

How to use credit service with an input? #39

Closed alexc101 closed 7 years ago

alexc101 commented 7 years ago

Is there an example on how to attach the service to an input? Been trying to call the service through (input) / (keydown) etc inside a custom directive but not having much luck and can't find anything in the repo which shows how it works.

(https://github.com/born2net/Angular-kitchen-sink/blob/master/src/services/CreditService.ts)

Sorry if this is inappropriate - thanks!

born2net commented 7 years ago

simply import in the constructor: constructor(private cc:CreditService) and call appropriate methods cc.validateCardNumber('4111111111111111')