Angular学习并踩坑

路由的使用小记

根模块中使用是RouterModule.forRoot,子模块中是RouterModule.forChild;
模块懒加载 loadChildren;
当前导航高亮routerLinkActive="active",完全匹配使用[routerLinkActiveOptions]="{ exact: true }";

RouterModule.forRoot([{
      path: '',
      children: [{
        path: '',
        redirectTo: '/main/list',
        pathMatch: 'full',
      },{
        path: 'main',
        loadChildren: 'app/main/main.module#MainModule'
      },{
        path: 'user',
        loadChildren: 'app/user/user.module#UserModule'
      }]
    }])

关于Angular Material

styles.css中引入预制主题样式报错

@import "~@angular/material/prebuilt-themes/indigo-pink.css";

改成

@import "@angular/material/prebuilt-themes/indigo-pink.css";

之后使用table组件的时候发现checkbox样式错误,折腾好久没找到原因。

Can't bind to 'ngModel' since it isn't a known property of 'label'

需要在模块里引入FormsModule,以前遇到过,总是忘...

import { FormsModule } from '@angular/forms';
Comments
Write a Comment