Sfoglia il codice sorgente

加入页面和二级路由

徐明 5 anni fa
parent
commit
f03db843cb

CasinosManager/src/app/app.component.css → CasinosManager/src/app/account/account.component.css


+ 3 - 0
CasinosManager/src/app/account/account.component.html

@@ -0,0 +1,3 @@
+<p>
+  account works!
+</p>

+ 15 - 0
CasinosManager/src/app/account/account.component.ts

@@ -0,0 +1,15 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+  selector: 'app-account',
+  templateUrl: './account.component.html',
+  styleUrls: ['./account.component.css']
+})
+export class AccountComponent implements OnInit {
+
+  constructor() { }
+
+  ngOnInit() {
+  }
+
+}

+ 32 - 0
CasinosManager/src/app/app-routing.module.ts

@@ -0,0 +1,32 @@
+import { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+import { AccountComponent } from './account/account.component';
+import { ContentComponent } from './content/content.component';
+
+const routes: Routes = [
+  { path: '', redirectTo: '/app/home', pathMatch: 'full' },
+  {
+    path: 'account',
+    component: AccountComponent
+  },
+  {
+      path: 'content',
+      component: ContentComponent,
+      children: [
+        {
+          path: '',
+          loadChildren: './content/content.module#ContentModule'
+        },
+      ]
+  },
+  
+];
+
+
+@NgModule({
+  imports: [
+    RouterModule.forRoot(routes, { useHash: true })
+  ],
+  exports: [RouterModule]
+})
+export class AppRoutingModule { }

File diff suppressed because it is too large
+ 0 - 20
CasinosManager/src/app/app.component.html


+ 0 - 27
CasinosManager/src/app/app.component.spec.ts

@@ -1,27 +0,0 @@
-import { TestBed, async } from '@angular/core/testing';
-import { AppComponent } from './app.component';
-describe('AppComponent', () => {
-  beforeEach(async(() => {
-    TestBed.configureTestingModule({
-      declarations: [
-        AppComponent
-      ],
-    }).compileComponents();
-  }));
-  it('should create the app', async(() => {
-    const fixture = TestBed.createComponent(AppComponent);
-    const app = fixture.debugElement.componentInstance;
-    expect(app).toBeTruthy();
-  }));
-  it(`should have as title 'CasinosManager'`, async(() => {
-    const fixture = TestBed.createComponent(AppComponent);
-    const app = fixture.debugElement.componentInstance;
-    expect(app.title).toEqual('CasinosManager');
-  }));
-  it('should render title in a h1 tag', async(() => {
-    const fixture = TestBed.createComponent(AppComponent);
-    fixture.detectChanges();
-    const compiled = fixture.debugElement.nativeElement;
-    expect(compiled.querySelector('h1').textContent).toContain('Welcome to CasinosManager!');
-  }));
-});

+ 1 - 2
CasinosManager/src/app/app.component.ts

@@ -2,8 +2,7 @@ import { Component } from '@angular/core';
 
 @Component({
   selector: 'app-root',
-  templateUrl: './app.component.html',
-  styleUrls: ['./app.component.css']
+  template: `<router-outlet></router-outlet>`
 })
 export class AppComponent {
   title = 'CasinosManager';

+ 9 - 2
CasinosManager/src/app/app.module.ts

@@ -1,14 +1,21 @@
 import { BrowserModule } from '@angular/platform-browser';
 import { NgModule } from '@angular/core';
+import { AppRoutingModule } from './/app-routing.module';
 
 import { AppComponent } from './app.component';
+import { AccountComponent } from './account/account.component';
+import { ContentComponent } from './content/content.component';
+
 
 @NgModule({
   declarations: [
-    AppComponent
+    AppComponent,
+    AccountComponent,
+    ContentComponent
   ],
   imports: [
-    BrowserModule
+    BrowserModule,
+    AppRoutingModule
   ],
   providers: [],
   bootstrap: [AppComponent]

+ 20 - 0
CasinosManager/src/app/content/content-routing.module.ts

@@ -0,0 +1,20 @@
+import { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+
+import { StudentComponent } from './student/student.component';
+import { CourseComponent } from './course/course.component';
+
+const routes: Routes = [
+  { path: '', redirectTo: 'student', pathMatch: 'full' },
+  { path: 'student', component: StudentComponent },
+  { path: 'course', component: CourseComponent },
+]
+
+
+@NgModule({
+  imports: [
+    RouterModule.forChild(routes)
+  ],
+  exports: [RouterModule]
+})
+export class ContentRoutingModule { }

+ 0 - 0
CasinosManager/src/app/content/content.component.css


+ 1 - 0
CasinosManager/src/app/content/content.component.html

@@ -0,0 +1 @@
+<router-outlet></router-outlet>

+ 15 - 0
CasinosManager/src/app/content/content.component.ts

@@ -0,0 +1,15 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+  selector: 'app-content',
+  templateUrl: './content.component.html',
+  styleUrls: ['./content.component.css']
+})
+export class ContentComponent implements OnInit {
+
+  constructor() { }
+
+  ngOnInit() {
+  }
+
+}

+ 22 - 0
CasinosManager/src/app/content/content.module.ts

@@ -0,0 +1,22 @@
+import { NgModule, APP_INITIALIZER, Injector } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+
+import { ContentRoutingModule } from './/content-routing.module';
+
+import { StudentComponent } from './student/student.component';
+import { CourseComponent } from './course/course.component';
+
+
+@NgModule({
+  imports: [
+    CommonModule,
+    FormsModule,
+    ContentRoutingModule
+  ],
+  declarations:[
+    StudentComponent,
+    CourseComponent
+  ]
+})
+export class ContentModule { }

+ 0 - 0
CasinosManager/src/app/content/course/course.component.css


+ 3 - 0
CasinosManager/src/app/content/course/course.component.html

@@ -0,0 +1,3 @@
+<p>
+  course works!
+</p>

+ 25 - 0
CasinosManager/src/app/content/course/course.component.spec.ts

@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { CourseComponent } from './course.component';
+
+describe('CourseComponent', () => {
+  let component: CourseComponent;
+  let fixture: ComponentFixture<CourseComponent>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ CourseComponent ]
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(CourseComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 15 - 0
CasinosManager/src/app/content/course/course.component.ts

@@ -0,0 +1,15 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+  selector: 'app-course',
+  templateUrl: './course.component.html',
+  styleUrls: ['./course.component.css']
+})
+export class CourseComponent implements OnInit {
+
+  constructor() { }
+
+  ngOnInit() {
+  }
+
+}

+ 0 - 0
CasinosManager/src/app/content/student/student.component.css


+ 3 - 0
CasinosManager/src/app/content/student/student.component.html

@@ -0,0 +1,3 @@
+<p>
+  student works!
+</p>

+ 15 - 0
CasinosManager/src/app/content/student/student.component.ts

@@ -0,0 +1,15 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+  selector: 'app-student',
+  templateUrl: './student.component.html',
+  styleUrls: ['./student.component.css']
+})
+export class StudentComponent implements OnInit {
+
+  constructor() { }
+
+  ngOnInit() {
+  }
+
+}