JavaScript Edu Resources. Angular Courses. React Tutorials. Join us!

Using NativeScript

  • We have only just started looking at NativeScript, but was pleasantly surprised to see how easy it is to port Angular code to native device code.
  • In the native world we can no longer write standard html views, so we have to get used to new ui elements and layout schemes.
  • import {Component} from ‘@angular/core’; import {Subject} from ‘rxjs/Subject’; @Component({ selector: ‘adder’, template: `
  • subscribe(res => { this.calculation = {sum:res.reduce((a,b) => a + b)}; this.showSum = true; }); } }

    The only exception is of course the template where we have to get used to new elements like Label and Button.

  • service’; @Component({ selector: ‘insertion-sort’, templateUrl: providers: [InsertionSortService] }) export class InsertionSortComponent { @Input() list:ValList; btnText = ‘Sort’; constructor(private sortingService: InsertionSortService){ this.list = new ValList(); this.list.items = [ new ListItem(5), new ListItem(33), new ListItem(5), new ListItem(4), new ListItem(88), new ListItem(40), new ListItem(-88), new ListItem(6), new ListItem(1), new ListItem(58), new ListItem(30) ]; } sortList(){ } } class ValList{ items:Array

    Notice in this sample we are using templateUrl instead of an inline template.

Using NativeScript with Angular

Comments are closed, but trackbacks and pingbacks are open.