This is a proof of concept that demonstrates the ability to share a Typescript package with core functionalities and business logic between an Angular web app and an Ionic mobile app.
Please check the Medium article Hybrid mobile apps: sharing logic between Angular and Ionic apps for more info.
Prerequisites:
* [Typescript 2.0+](https://www.typescriptlang.org/index.html#download-links)
* [Angular CLI](https://cli.angular.io)
* [Ionic CLI](http://ionicframework.com/docs/cli/)
Note: `ngrx-demo-core` module is shared between the apps with `npm link` but it could be published to `npmjs` and be used as a regular dependency.
### ngrx-demo-core module
First, compile `ngrx-demo-core` shared module.
It is based on official Ionic module template, which supports Angular's ngc and Ahead-of-Time compiling out of the box.
https://github.com/driftyco/ionic-module-template
cd ngrx-demo-apps/core
yarn
yarn build
yarn link
The shared module is now installed locally and can be used in other local npm projects.
### ngrx-demo-web app
Install or link `ngrx-demo-core` shared module and run the web app.
cd ../web
yarn
yarn link "ngrx-demo-core"
ng serve
### ngrx-demo-mobile app
As we did for the web app, install or link the `ngrx-demo-core` shared module and run the mobile app.
cd ../mobile
yarn
yarn link "ngrx-demo-core"
ionic serve
Note: for more info on using external lib on Ionic2
* [Third Party libraries in Ionic Apps](http://ionicframework.com/docs/v2/resources/third-party-libs/)
* [App Scripts](http://ionicframework.com/docs/v2/resources/app-scripts/)
## Bugs and feedback
If you have any questions or suggestions to improve the demo app, don't hesitate to submit an issue or a pull request!