This repository contains schematics for generating components in NativeScript Angular apps using the Angular CLI.
You should be using @angular/cli@9.1.0
or newer.
npm i -g @angular/cli
npm i -g @nativescript/schematics
To generate new NativeScript Angular project, you can use ng new
with @nativescript/schematics
specified as the schematics collection.
ng new --collection=@nativescript/schematics my-mobile-app
You can specify the following options when generating new applications:
Option | Description | Default |
---|---|---|
prefix | The prefix to apply to generated selectors. | app |
theme | Specifies whether the {N} css theme should be included. | true |
style | Specifies whether the app should use 'css' or 'scss' files for styling. | css |
webpack | Specifies whether the app will be ready for building with webpack. | true |
ng new --collection=@nativescript/schematics my-shared-app --shared
You can specify the following options when generating new applications:
Option | Description | Default |
---|---|---|
sourceDir | The name of the source directory. | src |
prefix | The prefix to apply to generated selectors. | app |
theme | Specifies whether the {N} css theme should be included. | true |
style | Specifies whether the app should use 'css' or 'scss' files for styling. | css |
sample | Generates an eagerly loaded module and master-detail navigation. | false |
@nativescript/schematics
in an existing projectYou need to add an angular.json
configuration file to your NativeScript project root directory. That will allow you to use Angular CLI for generating components.
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"cli": {
"defaultCollection": "@nativescript/schematics"
},
"projects": {
"project-name": {
"root": "",
"sourceRoot": ".",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
}
}
},
"defaultProject": "project-name"
}
Note: If you created your project with
ng new
, your project already hasangular.json
.
You can generate it the configuration using Schematics
. Install Schematics globally
npm install -g @angular-devkit/schematics-cli
From inside your project call:
schematics @nativescript/schematics:angular-json --name=project-name
You can use the ng generate
(or just ng g
) command to generate pretty much any Angular building unit - components, modules, directives, classes and so on. For the full list, check out the Angular CLI repo.Some of these generators are overwritten in NativeScript Schematics to suite the needs of a NativeScript Angular application.
To generate a component, call:
ng g c component-name
To generate a module, call:
ng g m module-name
To generate a component in an existing module folder, call:
ng g c module-name/component-name
You can use ng generate migrate-component
to convert a web Component to a shared component.This includes the following steps:
component-name
.component.tns.html.tns
parent module - note that the module-name
.module.tns.ts need to exist before you execute the command, or just use the --skipModule
flagParams:
required
- name of the component to be migrated - do not include the word Component
optional
- the location of the component file, do not include src/app
, i.e. home/home.component.ts
- use if the componentPath cannot be derived from the parent moduleoptional
- the name of the parent module - do not include the word Module
, leave empty if using the default EntryModule (AppModule
)optional
- the location of the parent module file, do not include src/app
, i.e. home/home.module.ts
- use if the module is not located at the root/app
(by default: src/app
)optional
- use if you don't want the module to be used for finding the component, and if you don't want to add the Component to Modules providersYou can use ng generate migrate-module
to convert a Web Module to a Shared Module and also convert all of its Components.This includes the following steps:
module-name
.component.tns.tsmigrate-component
schematicIn a code sharing project to build:
web
app call: ng serve
,iOS
app call: tns run ios
,Android
app call: tns run android
To generate a Master Detail module, you can use the following commandng g master-detail --master=dogs --detail=dog
The above command will generate the following file structure
Option | Description |
---|---|
master | The name of the master component and the name of the module. |
detail | The name of the detail component |
NativeScript 简介 - 知乎
This repo only supports NativeScript pre-6.0. The latest version of the plugin supporting NS 6+ is availble as part of ProPlugins. NativeScript Azure Mobile Apps plugin A NativeScript Azure Mobile App
Laravel Schematics This package allows you to make multiple diagrams of your Eloquent models and their relations.It will help building them providing drag and drop relations, forms to create and edit
我在试着更新Angular。因此,我在我用vs-2015创建的Angular项目中从CMD运行,结果在我的项目中得到了另一个错误: 错误TS2345类型“{Imports:typeof BrowserModule[];Declarations:typeof AppComponent[];Bootstrap:typeof AppComp...”得参数不能分配给类型“NGModule”得参数. 类型“
NativeScript Angular This repository contains the code for integration of NativeScript with Angular. NativeScript is a framework which enables developers to write truly native mobile applications for
Bitwarden Mobile Application The Bitwarden mobile application is written in C# with Xamarin Android, Xamarin iOS, and Xamarin Forms. Build/Run Requirements Visual Studio Xamarin Run the app Open the s
NativeScript 可以使用 Javascript,CSS, XML 创建真正的 Native 跨平台应用,支持 iOS Android,NativeScript 将您的跨平台代码翻译成目标平台的代码。 UI 使用 XML 描述,CSS 样式,在编译时将 UI 转化成本地原生代码,最终得到正在的 Native 原生应用。 Telerik 公开了用于创建安卓、iOS和Windows Unive