Angular

Angular

Angular

install

1
2
npm config set registry https://registry.npm.taobao.org
sudo npm install -g @angular/cli

修改主页

app.component.html src/style.css

添加组件

1
ng generate component kanban

添加模块带路由

1
ng generate module --routing your_module

devui

install

1
npm i ng-devui

angular开发环境

emacs下

1
2
3
4
5
6
7
8
(use-package ng2-mode
  :ensure t)
(use-package tide
  :ensure t
  :after (typescript-mode company flycheck)
  :hook ((typescript-mode . tide-setup)
         (typescript-mode . tide-hl-identifier-mode)
         (before-save . tide-format-before-save)))

缩进设置

1
2
3
4
5
6
7
8
➜  ~ cat ~/tsfmt.json
{
  "indentSize": 4,
  "tabSize": 4,
  "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
  "placeOpenBraceOnNewLineForFunctions": false,
  "placeOpenBraceOnNewLineForControlBlocks": false
}

FAQ

ng new setTimeout is not defined

因为是cpnpm安装的angular cli导致

1
2
sudo npm uninstall -g angular@cli
sudo npm install -g angular@cli

ng new too slow

因为部分还是走了外网,不是国内源

1
2
3
ng new projects-path --skip-install=true
cd projects-path
npm install

npm提示有proxy

1
2
3
4
add to your ~/.npmrc
https_proxy=null
https-proxy=null
proxy=null

Cannot find module '@ngx-translate/core'

NullInjectorError: No provider for HttpClient!

app.module需要引入HttpClient module

1
import { HttpClientModule } from '@angular/common/http';

error TS2564: Property 'busy' has no initializer and is not definitely assigned in the constructor.

1
busy?: Subscription

e implicitly has an 'any' type

1
(e: any)

建议显式声明类型

bundle initial exceeded maximum budget. Budget 1.00 MB

angular.json搜索budgets修改对应的大小即可

angular not going to children, but root

like /a/b.component.html add <router-outlet></router-outlet> to root a.component.html

参考文档