[英]Angular 5 routerLink
I have added the routerLink in the button under product.component.html which will redirect to /update-product. 我在product.component.html下的按钮中添加了routerLink,它将重定向到/ update-product。 Below is the code:
下面是代码:
<button routerLink="./update-product" routerLinkActive="active">Edit</button>
When I submit the button, its not redirecting however, no error in the console. 当我提交按钮时,它不会重定向,但是控制台中没有错误。
My product.component.ts is as below: 我的product.component.ts如下:
import { Component, OnInit } from '@angular/core';
import {Title} from "@angular/platform-browser";
import { ProductService } from './product.service';
import { Product } from './product';
import { HttpErrorResponse } from '@angular/common/http';
@Component({
selector: 'app-product',
templateUrl: './product.component.html',
styleUrls: ['./product.component.scss'],
providers: []
})
export class ProductComponent implements OnInit {
products: Product[] = [];
dataInvalid = false;
formErrors = [];
formSubmitting = false;
//title = 'Products';
countries = [];
states = [];
constructor(private productService: ProductService, private title: Title) { }
您将必须按照以下方式进行操作。
<button routerLink="/update-product" routerLinkActive="active">Edit</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.