欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

angular2模塊和共享模塊詳解

 更新時間:2018年04月08日 08:38:54   作者:孟繁洋  
這篇文章主要介紹了angular2模塊和共享模塊詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

創(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)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Angular?@Injectable注解的工作原理解析

    Angular?@Injectable注解的工作原理解析

    這篇文章主要為大家介紹了Angular?@Injectable注解的工作原理解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-06-06
  • Angular2  NgModule 模塊詳解

    Angular2 NgModule 模塊詳解

    這篇文章主要介紹了Angular2 NgModule 模塊詳解的相關(guān)資料,并附簡單實例,需要的朋友可以參考下
    2016-10-10
  • 將angular-ui的分頁組件封裝成指令的方法詳解

    將angular-ui的分頁組件封裝成指令的方法詳解

    這篇文章主要給大家介紹了將angular-ui的分頁組件封裝成指令的方法,文中介紹的非常詳細,相信會對大家的學習或者工作覺有一定的參考價值,需要的朋友下面來一起看看吧。
    2017-05-05
  • AngularJs bootstrap詳解及示例代碼

    AngularJs bootstrap詳解及示例代碼

    本文主要講解AngularJs bootstrap,這里整理了詳細的資料及簡單示例代碼幫助大家學習或者參考,有需要的小伙伴看下
    2016-09-09
  • angular過濾器實現(xiàn)排序功能

    angular過濾器實現(xiàn)排序功能

    這篇文章主要為大家詳細介紹了angular過濾器實現(xiàn)排序功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • AngularJS控制器controller正確的通信的方法

    AngularJS控制器controller正確的通信的方法

    AngularJS中的controller是個函數(shù),用來向視圖的作用域($scope)添加額外的功能,我們用它來給作用域?qū)ο笤O(shè)置初始狀態(tài),并添加自定義行為
    2016-01-01
  • AngularJS的內(nèi)置過濾器詳解

    AngularJS的內(nèi)置過濾器詳解

    在我們開發(fā)中經(jīng)常需要在頁面顯示給用戶的信息需要一定處理格式化,才能顯示給用戶。在angularjs中為我們提供了叫filter的指令,讓我們能夠很輕易就能做到著一些列的功能,angularjs內(nèi)部為我們提供了number等很多內(nèi)置的filter。
    2015-05-05
  • Angular4 組件通訊方法大全(推薦)

    Angular4 組件通訊方法大全(推薦)

    這篇文章主要介紹了Angular4 組件通訊方法大全(推薦),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-07-07
  • AngularJS通過$sce輸出html的方法

    AngularJS通過$sce輸出html的方法

    不知道大家有沒有發(fā)現(xiàn)在用AngularJS作為前端搭建個人博客的時候,發(fā)現(xiàn)用AngularJs輸出html的時候,瀏覽器并不解析這些html標簽,這里我們需要其顯示angular輸出的html能被瀏覽器解析怎么辦呢?不知道Angularjs如何實現(xiàn)這種功能的通過這篇文章來看看吧。
    2016-09-09
  • 詳解AngularJS Filter(過濾器)用法

    詳解AngularJS Filter(過濾器)用法

    這篇文章主要介紹了AngularJS的filter,中文名“過濾器”是用來過濾變量的值,或者格式化輸出,得到自己所期望的結(jié)果或格式的東東,的相關(guān)資料,需要的朋友可以參考下
    2015-12-12

最新評論