将ObservableArray传递给Model对话框参数显示RadListView数据有[Object Object]

loading...


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: (Modal dialog)

public firstAppArr: ObservableArray<App>;

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

    ngOnInit() {

        this.firstAppArr= this.params.context;
    }

first_component.html: (Modal dialog 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>

loading...

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;
    }
    

    访问对象的数组部分 .

评论

暂时没有评论!