Angular 4错误无法分配为只读对象'[object Object]'的属性'groups'

时间:2019-06-05 20:39:59

标签: angular apollo apollo-client

我收到此错误无法分配为仅读取对象'[object Object] 的属性'groups'。我正在使用Angular 4和Apollo Client。

        this.listUsers = this.serv.getUsersES((this.currentPage - 1) * 10, 10, this.word_filter, this.status).map(
            resp => {
                resp.data.getUsersES.items.map(element => {
                    if (element.groups) {
                        let groups_tmp = [];
                        element.groups.forEach(g => {
                            let e = "";
                            this.allgroups.forEach((gr) => {
                                if (gr.name == g)
                                    e = gr.display_name;
                            });
                            groups_tmp.push(e);
                        });
                        element.groups = groups_tmp;
                    }
                });

                return resp;
            }
        );

更新

我已经完成了用户告诉我的penleychan,但是它也不起作用。这将返回一个空数组。

        this.listUsers = this.serv.getUsersES((this.currentPage - 1) * 10, 10, this.word_filter, this.status).map(
            resp => {
                return resp.data.getUsersES.items.map(element => {
                    if (element.groups) {
                        let groups_tmp = [];
                        element.groups.forEach(g => {
                            let e = "";
                            this.allgroups.forEach((gr) => {
                                if (gr.name == g)
                                    e = gr.display_name;
                            });
                            groups_tmp.push(e);
                        });
                        return groups_tmp;
                    }
                });
            }
        );

谢谢。

0 个答案:

没有答案