Archives quotidiennes :

Nativescript 6 with Angular 10

[Reminder] With Nativescript 7 released, this article is now meaningless.

Sources:

As of August 28, 2020, standard installation produce an angular 8 application.

The purpose of this article is to generate a functional application with angular 10.

Install NativeScript release candidate

npm i -g nativescript@rc

Generate a hello-world application

nsc create sampleapp –template @nativescript/template-hello-world-ng

use SASS by default

  1. install node-sass :
    npm i --save-dev node-sass
  2. rename app.css in app.scss
  3. replace in app.scss :
@import "~@nativescript/theme/css/core.css";
@import "~@nativescript/theme/css/default.css";

by

@import "~@nativescript/theme/core";
@import "~@nativescript/theme/default";
  1. change in angular.son
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "cli": {
    "defaultCollection": "@nativescript/schematics"
  },
  "projects": {
    "hello-world": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "ns",
      "schematics": {
        "@nativescript/schematics:component": {
          "style": "scss"
        }
      }
    }
  },
  "defaultProject": "hello-world"
}

Add a login page

ng generate component login
ng generate service services/user
ng generate class models/user --type=model

Test your application

nsc run ios –emulator