You want to have an application that can be run as a standalone and you can pack it as a library that can be published to NPM and then reused (installed) inside other applications? You can use Angular CLI to generate your application, and ng-packagr to pack it and publish it.
You can also use this tutorial just to see how you can pack and publish your application as a library.
Blog
Posted by Amphinicy Blogger
Thursday, Aug 23, 2018
Many Angular developers are asking a question about what is a counterpart of a $compile() function of AngularJs in Angular (2+). In AngularJs you were able to append a string with some HTML markup and AngularJs directives to a template and use $compile() function to generate a fully functional view. In Angular there is no $compile() function, so you need to use other tricks to achieve a similar result.