title: How to Get a parameter from one place to another in same page in angular 2,4
body: <p>I have an interface in which interface  I get a popup search tab with an editable list.</p>
  
  <p>But I am not aware of the method to get data to the main interface for edit after I click this list edit button.
  (Like this <a href="https://stackblitz.com/angular/xvnyldqvjqp" rel="nofollow noreferrer">https://stackblitz.com/angular/xvnyldqvjqp</a>)</p>
  
  <p>Simply what I need is to pass the id of the current item to main edit view as a parameter. (ie, here I have a page name New stock count. In this page, I want to like this. ( When searching an item it will be displayed and then I click to the pencil or the item, the clicked items are displayed in the left side ( Here the clicked items are taking by the parameter named <code>itemid</code>, <code>userid</code> and <code>shopid</code>. But here I didn't get the <code>itemid</code> params when using alert I got undefined <code>itemid</code>)))
  If anybody knows this its a big help for me</p>
  
  <p><strong>My code:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/eIhtl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eIhtl.png" alt="enter image description here"></a></p>
  
  <p><strong>This is my TS file:</strong></p>
  
  <pre><code>Editmodeclose(value: any) {
      let ItemID: number = this._activatedRoute.snapshot.params['code'];
  
      alert(this.userid);
      alert(this.shopid);
      alert(ItemID); //(here item id show undefined)
      this._enqService.FetchStockitem(ItemID, this.shopid, this.userid)
        .subscribe(
          defaultdatas =&gt; this.defaultdata = defaultdatas,
          error =&gt; {
            console.error(error);
            this.statusMessage = "Problem with the service.Please try again after sometime";
        });
      $("#SearchModal").modal("hide");
  }
  </code></pre>
  
  <p>My html file(Search item listed html)</p>
  
  <pre><code>&lt;ng-container *ngFor="let stocks of stockdetail;"&gt;
                      &lt;a [routerLink]="['/NewStockCount',stocks.ItemID]"&gt;
                          &lt;div class="row searchItem" style="margin:0px;"&gt;
                              &lt;!--search item starts--&gt;
                              &lt;div class="col-md-10 col-sm-10 col-xs-12"&gt;
                                  &lt;div class="row"&gt;
                                      &lt;div class="col-md-6 col-sm-6 col-xs-12"&gt;
  
                                          &lt;label&gt;Item&lt;/label&gt;
                                          &lt;span&gt;{{stocks.ItemID}}&lt;/span&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-md-6 col-sm-6 col-xs-12"&gt;
  
                                          &lt;label&gt;Item Code&lt;/label&gt;
                                          &lt;span&gt;{{stocks.ItemCode}}&lt;/span&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-md-6 col-sm-6 col-xs-12"&gt;
                                          &lt;label&gt;Item Desc&lt;/label&gt;
                                          &lt;span&gt;{{stocks.ItemDescription}}&lt;/span&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-md-6 col-sm-6 col-xs-12"&gt;
                                          &lt;label&gt;Packing Type&lt;/label&gt;
                                          &lt;span&gt;{{stocks.PackingtypeName}}&lt;/span&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-md-6 col-sm-6 col-xs-12"&gt;
                                          &lt;label&gt;Stock&lt;/label&gt;
                                          &lt;span&gt;{{stocks.Stock}}&lt;/span&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
  
                              &lt;div class="col-md-2 col-sm-2 col-xs-12 text-right"&gt;
                                  &lt;span class="btn btn-success Editmode-Btn" (click)="Editmodeclose()"&gt;&lt;i class="glyphicon glyphicon-pencil"&gt;&lt;/i&gt;&lt;/span&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/a&gt;   &lt;/ng-container&gt;
  </code></pre>
  
  <p>Left side display item html(want to display items here)</p>
  
  <pre><code>  &lt;div class="row"&gt;
                              &lt;div class="col-md-12 col-sm-12 col-xs-12"&gt;
                                  &lt;div class="form-group"&gt;
                                      &lt;label&gt;Item Code&lt;/label&gt;
                                      &lt;ng-container *ngFor="let items of defaultdata;"&gt;
                                          &lt;span&gt;{{items.ItemCode}}&lt;/span&gt;
                                      &lt;/ng-container&gt;
                                    &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;.....etc......
  </code></pre>