How to add click event on mat-row in angular material table

后端 未结 5 699
时光说笑
时光说笑 2020-12-28 14:23

I added this but when inspecting element using Chrome DevTools, the click function doesn\'t show!

Here\'s my code:



        
5条回答
  •  醉酒成梦
    2020-12-28 14:45

    If some body needs to use a router link you can do it like bellow:

    
    
    

    you should create a route to match the link, for example:

    const routes: Routes = [
      {
        path:'editnews/:newsfeedid', component:NewsfeedformComponent
      }
    ]
    

    If you want to get the id from url in your component, under ngOnInit use ActivatedRoute like bellow:

    import { ActivatedRoute } from '@angular/router';
    
    ngOnInit() {
    this._activatedRoute.paramMap.subscribe(params => {
    // in the route we created edit route we set newsfeedid as param so we get it here
      const NewsfeedID = +params.get('newsfeedid');
      if (NewsfeedID) {
        //this.getAgentbyid(agentid);
        console.log(NewsfeedID);
        }
     })
    }
    

提交回复
热议问题