1. 程式人生 > >Angular學習筆記

Angular學習筆記

Angular Help Repository CKEditor Doc

NPM幫助

npm help
npm -l 列出所有命令用法
npm \<cmd> -h 查看某一命令用法,如:
npm ls -h
npm help npm 在瀏覽器中查看幫助文檔,如:
npm help index (Index of all npm documentation)
npm help folders
npm help install

ng幫助

ng help 顯示所有命令的幫助
ng help -s 僅顯示命令名稱和描述
ng help \<command-name> 顯示某一命令的幫助

Updating Angular CLI

To update Angular CLI to a new version, you must update both the global package and your project‘s local package.

Global package:

npm uninstall -g @angular/cli  
npm cache clean  
# if npm version is > 5 then use `npm cache verify` to avoid errors (or to avoid using --force)  
npm install -g @angular/cli@latest

Local project package:

# use rmdir /S/Q node_modules dist in Windows Command Prompt;  
# use rm -r -fo node_modules,dist in Windows PowerShell  
rm -rf node_modules dist  
npm install --save-dev @angular/cli@latest  
npm install 

一次升級 package.json的所有版本

需使用npm-check-updates工具
# 安裝npm-check-updates
npm i -g npm-check-updates
# 升級
ncu -u
# 安裝新版本
npm install

運行npm ls可查看版本是否匹配。
運行npm view \<package>可查看某一package發布的版本,如:
npm view ngx-bootstrap [versions]
進入package目錄下,運行npm version可查看安裝的版本。

package.json中的version語法請參見The semantic versioner for npm

搭建NPM私服

推薦使用Nexus,概念和配置方法同Maven私服一致,分為proxy、hosted、group三類。
創建proxy如下:
技術分享圖片
Remote URL: https://registry.npmjs.org
然後創建hosted、group,不再贅述。
最後在home下創建.npmrc文件,其內填寫public地址,如下:
registry=http://localhost:8081/repository/npm-public/

Cannot find module ‘node-sass‘

npm install node-sass --no-bin-links

Angular - CKEditor component

  1. Include CKEditor javascript files in your application
    <script src="https://cdn.ckeditor.com/4.7.3/full-all/ckeditor.js"></script>
  2. Install ng2-ckeditor
    npm install --save ng2-ckeditor
    3.Include CKEditorModule in your main module

import { CKEditorModule } from ‘ng2-ckeditor‘;

@NgModule({
// ...
imports: [
CKEditorModule
],
// ...
})
export class AppModule { }

  1. usage
    <ckeditor [(ngModel)]="content" [config]="{extraPlugins: ‘divarea‘}" name="editor"></ckeditor>

Angular文檔

Angular
Angular中文
Angular中文社區
Angular 4.x 修仙之路
TypeScript
TypeScript中文網
Angular CLI
NPM Docs
RxJS
Angular HTTP Client - Quickstart Guide
Angular Architecture - Smart Components vs Presentational Components
Multiple solutions for Angular Ahead of Time (AOT) Compilation
Angular - CKEditor component

Angular學習筆記