This article mainly introduces the detailed explanation of angular2 module and shared module. Now I will share it with you and give you a reference.
To create the module, the shared module PostSharedModule is used. The shared module contains two common modules: article management module and comment management module
1, create a module 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. Create module routing 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' } ] } ];
<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>
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 { }
Ajax cross-domain (same basic domain name) form submission method
AJAX submission form data example Analysis
A brief discussion on Ajax and its advantages and disadvantages
# #
The above is the detailed content of Detailed explanation of angular2 modules and shared modules. For more information, please follow other related articles on the PHP Chinese website!