Using code in multiple pages

hi,
i want to use some code (autocomplete search bar) in few pages.
how tried providers and services as well. same problem:
i can’t use it outside the constructor.

Can you turn it into a custom component?

hi and thank you for the answer.
the ts i put already inside a service.
i mean the html - i have loop, list and few other things for the search bar.
is there a way put it one time outside somewhere and just call it?
in jquery it is pretty easy but in ionic i havn’t found a way yet…

Yes, that is called a custom component in Angular speech. You put the HTML, CSS and JS all together in a few files that then can be imported and used in other components.