簡體   English   中英

如何以角度2,4從同一位置的一個地方到另一個地方獲取參數

[英]How to Get a parameter from one place to another in same page in angular 2,4

我有一個界面,在該界面中,我會看到一個帶有可編輯列表的彈出式搜索標簽。

但是我不知道在單擊此列表編輯按鈕后將數據獲取到主界面進行編輯的方法。 (就像這個https://stackblitz.com/angular/xvnyldqvjqp

我只需要將當前項目的ID作為參數傳遞給主編輯視圖。 (即,我在這里有一個頁面名稱“新庫存計數”。在此頁面中,我想這樣。(在搜索項目時,將顯示該項目,然后單擊鉛筆或該項目,單擊的項目將顯示在左側(這里單擊的項目由名為itemiduseridshopid的參數接收。但是在使用警報時我沒有得到itemid參數,但得到未定義的itemid )))如果有人知道這對我有很大幫助

我的代碼:

在此處輸入圖片說明

這是我的TS文件:

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 => this.defaultdata = defaultdatas,
        error => {
          console.error(error);
          this.statusMessage = "Problem with the service.Please try again after sometime";
      });
    $("#SearchModal").modal("hide");
}

我的html文件(搜索項列出為html)

<ng-container *ngFor="let stocks of stockdetail;">
                    <a [routerLink]="['/NewStockCount',stocks.ItemID]">
                        <div class="row searchItem" style="margin:0px;">
                            <!--search item starts-->
                            <div class="col-md-10 col-sm-10 col-xs-12">
                                <div class="row">
                                    <div class="col-md-6 col-sm-6 col-xs-12">

                                        <label>Item</label>
                                        <span>{{stocks.ItemID}}</span>
                                    </div>
                                    <div class="col-md-6 col-sm-6 col-xs-12">

                                        <label>Item Code</label>
                                        <span>{{stocks.ItemCode}}</span>
                                    </div>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <label>Item Desc</label>
                                        <span>{{stocks.ItemDescription}}</span>
                                    </div>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <label>Packing Type</label>
                                        <span>{{stocks.PackingtypeName}}</span>
                                    </div>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <label>Stock</label>
                                        <span>{{stocks.Stock}}</span>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-2 col-sm-2 col-xs-12 text-right">
                                <span class="btn btn-success Editmode-Btn" (click)="Editmodeclose()"><i class="glyphicon glyphicon-pencil"></i></span>
                            </div>
                        </div>
                    </a>   </ng-container>

左側顯示項目html(想在此處顯示項目)

  <div class="row">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <div class="form-group">
                                    <label>Item Code</label>
                                    <ng-container *ngFor="let items of defaultdata;">
                                        <span>{{items.ItemCode}}</span>
                                    </ng-container>
                                  </div>
                            </div>
                        </div>.....etc......

只需在“編輯”按鈕中單擊“股票”對象,它將為您工作。

一些示例代碼;

<span class="btn btn-success Editmode-Btn" (click)="Editmodeclose(**stocks**)">
    <i class="glyphicon glyphicon-pencil">
    </i>
</span>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM