The first part of this post describes how you can get a JAX-RS endpoint running with an AngularJS2 app and
afterwards made some changes to get it running with basic authentication and CORS.
The following JavaEE backend is pretty standard (except of the definition of Application within
the resource which is usually done in a seperate class).
This AngularJS2 app is basically a small variation of the (AngularJS2 Quickstart)
and only displays the data from the JAX-RS endpoint.
If you now want to use basis authentication you have to do the following changes
Define a Http header with the necessary information
Pass it to the Http request
Add a JavaEECORS Filter
Omit Http-MethodOption for the secure JAX-RS endpoint otherwise you get a 401 for the preflight request