国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

angular2模塊和共享模塊詳解

2024-05-06 15:20:08
字體:
供稿:網(wǎng)友

創(chuàng)建模塊,用到了共享模塊PostSharedModule,共享模塊里面包含了2個公用的模塊:文章管理模塊和評論管理模塊

1,創(chuàng)建一個模塊testmodule.module.ts

import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { RouterModule } from "@angular/router"; import { <span style="color:#cc0000;"><strong>PostSharedModule </strong></span>} from '../shared/post.module'; import { testModule } from './testmodule.routes'; import { TestMainComponent } from './test-main/test-main.component'; import { PostTableService } from '../manage/post-table/services/post-table.service'; @NgModule({  declarations: [   TestMainComponent  ],  imports: [    CommonModule,    <span style="color:#ff0000;">PostSharedModule</span>,    RouterModule.forChild(testModule)  ],  exports:[   TestMainComponent  ],  providers: [   PostTableService  ] }) export class TestModule { } 

2.創(chuàng)建模塊路由testmodule.routes.ts

import { TestMainComponent } from './test-main/test-main.component'; import { PostTableComponent } from '../manage/post-table/post-table.component'; import { CommentTableComponent } from '../manage/comment-table/comment-table.component'; export const testModule = [   {     path:'',     component:TestMainComponent,     children: [       { path: '',redirectTo:'posttable/page/1',pathMatch:'full'},       { path: 'posttable/page/:page', component: PostTableComponent },       { path: 'commenttable/page/:page', component: CommentTableComponent },       { path: '**', redirectTo:'posttable/page/1' }     ]   } ]; 

3.執(zhí)行ng g c test-main,創(chuàng)建組件test-main,修改test-main.component.html

<a routerLink="posttable/page/1" class="list-group-item"><span class="badge">10000</span>文章管理</a>     <a routerLink="commenttable/page/1" class="list-group-item"><span class="badge">1000000</span>評論管理</a>

創(chuàng)建 共享模塊post.module.ts 

import { NgModule } from '@angular/core'; import { ModalModule } from 'ng2-bootstrap'; import { PaginationModule } from 'ng2-bootstrap'; import { SharedModule } from './shared.module'; import { CommentTableComponent } from '../manage/comment-table/comment-table.component'; import { PostTableComponent } from '../manage/post-table/post-table.component'; @NgModule({  imports:[    SharedModule,   ModalModule.forRoot(),   PaginationModule.forRoot()  ],  declarations:[    CommentTableComponent,    PostTableComponent  ],  exports:[    ModalModule,   PaginationModule,   CommentTableComponent,    PostTableComponent  ] }) export class PostSharedModule {   } 

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持錯新站長站。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 江源县| 泌阳县| 石景山区| 渝北区| 广河县| 安塞县| 山阴县| 铜梁县| 定西市| 台南县| 西充县| 彰武县| 宁夏| 台北市| 五常市| 门头沟区| 九寨沟县| 万山特区| 盱眙县| 丰镇市| 江油市| 吉安县| 靖西县| 中方县| 鸡西市| 喀什市| 阿鲁科尔沁旗| 新源县| 阜宁县| 达州市| 读书| 镇远县| 毕节市| 鄂托克旗| 乌兰察布市| 江阴市| 辽宁省| 贡嘎县| 马龙县| 荆州市| 布拖县|