Integrating NativeScript with Angular 2.
The project bundles the NativeScript modules and Angular as source code dependencies set up as git submodules. You need to get them by running:
$ git submodule update --init
Install your native toolchain and NativeScript as described in the docs:
https://docs.nativescript.org/setup/quick-setup
$ npm install -g grunt-cli gulp
Then install the needed NPM packages:
$ npm install
$ grunt prepare
$ cd ng-sample
$ npm install
$ grunt prepare
The latter installs the angular2
and tns-core-modules
packages that you just built by running grunt prepare
step in the project root.
$ grunt app
- Make changes to
src/nativescript-angular
, and rebuild withgrunt build
. If succesful, you should get a npm package in the project root. - Navigate to the ng-sample subdir:
$ cd ng-sample
. Make some changes to the app or../src/nativescript-angular
. - Compile app:
$ grunt app
- Run with
$ tns run android
or$ tns run ios
Protip: combine #2 and #3 above in a single command run from the project root directory (works only on Unixy shells):
$ grunt app && tns run android
On Windows, you can wrap those commands in a BAT file.
Note that you should never change files in ng-sample/src/nativescript-angular/
as they are overwritten with the reference sources in src/nativescript-angular
on every grunt app
run.
NativeScript session on AngularConnect conference
The ng-sample
app is meant for testing stuff while developing the renderer code, and isn't the best example out there. You can take a look at these sample apps that use the published builds from npm:
- There are certain issues with the Parse5DomAdapter and we'll likely need to provide our own later on: