【发布时间】:2019-04-01 17:17:58
【问题描述】:
我是 Angular 4 的新手。
我有一个包含 3 个组件的项目:根、组件 1 和组件 2。
当我点击主页中的按钮时,我将被导航到 google 组件页面,但问题是我在子组件页面中看到了我的主页按钮和图片。
我没有找到问题出在哪里,请任何帮助,这是我的组件代码。
-
app.modules.ts
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import {FormsModule} from '@angular/forms'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { PikachuComponent } from './pikachu/pikachu.component'; import { GoogleComponent } from './google/google.component'; @NgModule({ declarations: [ AppComponent, PikachuComponent, GoogleComponent ], imports: [ BrowserModule, AppRoutingModule, FormsModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } -
我的 app.component.html
<!--The content below is only a placeholder and can be replaced.--> <!doctype html> <html lang="fr"> <head> <style> body { background-image: url("../assets/Background.jpg"); background-size: cover; } #languageSwitch { text-align: right; } .centerContent { text-align: center; } /* Bootstrap override */ .btn-primary { color: #213239; font-weight: bold; background-color: white; border-color: white; border-radius: 50px; padding: 3px 30px 3px 30px; white-space: nowrap !important; min-width: 150px; margin: 0px 80px; } .btn-checkin { color: #213239; font-weight: bold; background-color: white; border-color: white; border-radius: 50px; padding: 3px 30px 3px 30px; white-space: nowrap !important; min-width: 150px; margin: auto; text-align: right; } .btn-group-lg > .btn, .btn-lg { padding: 5px 40px 5px 40px; min-width: 200px; } </style> </head> <body> <body> <img src="./assets/Quadri_medium_2lignes_transparent.png" class="center"> </body> <div style="text-align:center"> <h3>{{curTime() }}</h3> </div> <a target="_blank" rel="noopener" routerLink="/google"> <button class="btn-checkin" >Check In</button></a> <a target="_blank" rel="noopener" routerLink="/pikachu"> <button class="btn-primary">Check Out</button></a> </body> <router-outlet></router-outlet> </html> -
我的 google.component.html
名义 姓名为必填项 Prenom Prenom 是必需的 电子邮件地址 电子邮件地址为必填项<button type="submit" class="btn btn-success" [disabled]="!Visiteur.form.valid">Next</button> -
我的 index.html
<!doctype html> <html lang="fr"> <head> <style> body { background-image: url("../assets/GFIBackground.jpg"); background-size: cover; } #languageSwitch { text-align: right; } .centerContent { text-align: center; } /* Bootstrap override */ .btn-primary { color: #213239; font-weight: bold; background-color: white; border-color: white; border-radius: 50px; padding: 3px 30px 3px 30px; white-space: nowrap !important; min-width: 150px; margin: 0px 80px; } .btn-group-lg > .btn, .btn-lg { padding: 5px 40px 5px 40px; min-width: 200px; } .center { display: block; margin-left: auto; margin-right: auto; width: 30%; } </style> <meta charset="utf-8"> <title>Visiteur GFI</title> <base href="/"> </head> <app-root></app-root> </body> </html>
我知道它不是很干净,但我需要知道错误在哪里。
在此先感谢
【问题讨论】:
标签: html angular forms routing