0

我已将 Observable 数组传递给模态对话框参数。打开模态对话框时,我从 radlistview 中得到一个值,有 [object Object]。

但如果我使用 listview 它工作正常。只有使用 radlistview 我必须解决这个问题。

HomeComponent.ts:

 public obsArr: ObservableArray<App>;
    ngOnInit(){
        this.obsArr= this.homeService.getMyApps();
      }

       const options = {
            context: this.obsArr,
            fullscreen: true,
            viewContainerRef: this.vcRef
          };
          this.modal.showModal(FirstComponent, options).then((resource) => {
          });

FirstComponent.ts:( 模态对话框)

  public firstAppArr: ObservableArray<App>;

    constructor(private params: ModalDialogParams, private routerExtensions: RouterExtensions) {
    }

    ngOnInit() {

        this.firstAppArr= this.params.context;
    }

first_component.html:( 模态对话框 html)

<RadListView [items]="firstAppArr" itemReorder="true">
    <ng-template let-item="item" let-i="index">
        <GridLayout rows="auto" columns="*,*">
            <StackLayout col="0" horizontalAlignment="left" verticalAlignment="center">
                <Label [text]="item.name" textWrap="true"></Label>
            </StackLayout>

            <StackLayout col="1" horizontalAlignment="right" verticalAlignment="center">
                <Label [text]="item.description" textWrap="true"></Label>

            </StackLayout>     
        </GridLayout>
    </ng-template>      
</RadListView>
4

1 回答 1

0

现在你正在设置firstAppArr一个对象{"_observers":{}, "_array":[]},它不是你正在寻找的数组。我建议做的是把你改成ngOnInit()这个

ngOnInit() {
    // if you are guaranteed context and array
    this.firstAppArr = this.params.context._array;

    // if you aren't guaranteed context or array. this will either be _array or undefined
    this.firstAppArr = this.params && this.params.context. && this.params.context._array;
}

访问对象的数组部分。

于 2018-12-10T16:56:27.927 回答