Home

Awesome

NativeScript Ionic Template {N} apple android ionic

Native mobile Apps with NativeScript and Web Apps (Mobile First) with Ionic styles and components sharing the same code with Angular!

This template uses the default navigation of Angular, the navigation of Ionic 3 is not recommended to develop websites, therefore it is not recommended to use Ionic components that require Ionic navigation. However, in this template you can find an example of how to use components such as the side menu without depending on the navigation.

NativeScript and Ionic

Introduction 👨‍💻

Using this template you can create a Web App (Mobile First) using Ionic 3 components and a Mobile Native App using NativeScript with the same code, yay! 👏

Native and Web Grid

For more details you can check the excellent NativeScript team article about Code Sharing Between Web and Mobile with Angular and NativeScript: https://www.nativescript.org/blog/code-sharing-between-web-and-mobile-with-angular-and-nativescript

How does it work? ☕

Check the excellent video of Sebastian Witalec about Sharing Code Between Web and Native Apps

Sharing Code Between Web and Native Apps

Run the projects ⏯

  npm install (It's required to create the symlinks at the first time before to execute the app)
  ng serve
  cd nativescript
  npm install
  npm run livesync (Required to detect changes and reload the app from the simulator/device)
  npm run ios (using other terminal)

Commands 💻

View available commands here: Seed commands

Getting Started 📚

CommandAction
npm install -g @angular/cliInstall the Angular-cli. Remember see the documentation here
ng g module [name]Generate a new Module. Recommended to create sections of your app that will load components with Lazy Loading.
ng g component [name]Generate a new Component in the current directory. Remember add the moduleId property moduleId: module.id in every component
ng g service [name]Generate a new Service. The app/providers/ path is recommended for shared services among several components.

Use Ionic icons from the NativeScript side 🎁

NativeScript requires the unicode of the icon, you can find the unicode with the name of the icon from the content of the src/fonts/ionicons.svg file and later you can use it from a <Label> or <Button>, example:

// name: ion-ios-contact, unicode: &#xf41a;
<Button class="ion-icon" fontSize="25" text="&#xf41a;"></Button>

Custom templates for each platform 🥂

Target Phone and Tablet Templates individually. The following extensions are supported:

ExtensionPlatform
.{html/scss}Web platform. Used from mobile when there is no .tns extension
.tns.{html/scss}Only for mobile
.tns.ios.{html/scss}Only for iOS
.tns.android.{html/scss}Only for Android
.tns.ios.phone.{html/scss}Only for iOS Phone
.tns.android.phone.{html/scss}Only for Android Phone

Code Splitting

Angular Tips

Syntax                      MeaningExpected Result
{{ title }}<br/>{{ getTitle() }}Render a value dynamically, this expression will be evaluated at run time.
[src]="imageUrl"            Property Binding: Bind a property of a DOM element to a field of the component.
[attr.colspan]="colSpan"      Attribute Binding
[class.selected]="user.selected"Class Binding: Add a class dynamically.
[style.color]="isActive? 'green': 'red'"Style Binding
(tap)="onSave($event)"        Event Binding
(keyup.enter)="onEnter()"      Event Filtering
#email (keyup.enter)="onEnter(email.value)Template variables
[(ngModel)]="user.email"      Two-way Binding. Import FormsModule is required.
{{ price | currency:'AUD' }}  Pipes: Format data.
@Input('input-property') myData;<br/><example [input-property]="data">Input Properties: Input data for the component.
@Output('output-property') change= new EventEmitter();<br/>this.change.emit({msg: 'Hi!'});<br/><example (output-property)="onChange($event)"><br/>Output Properties: Raise events from the component.onChange({msg})<br/>{<br/>console.log(msg)<br/>}

Resources ⛩

Contributors 🥇

<img alt="Sean perkins" src="https://avatars1.githubusercontent.com/u/13732623?v=3&s=117" width="117"><img alt="jdnichollsc" src="https://avatars3.githubusercontent.com/u/2154886?v=3&s=117" width="117">
Sean PerkinsJuan Nicholls

Credits 👍

Supporting 🍻

I believe in Unicorns 🦄 Support me, if you do too.

Happy coding 💯

Made with ❤️

<img width="150px" src="http://phaser.azurewebsites.net/assets/nicholls.png" align="right">