小编Let*_*ima的帖子

类型 'Promise<any>' 缺少以下属性 angular

我正在 angular7 中建立到我的系统的 http 连接。但是,它在模块中出错。当我创建 get 请求时会出现此消息:

Type 'Promise<any>' is missing the following properties from type 'User': id, user, email
Run Code Online (Sandbox Code Playgroud)

模块:

export class User { 
  id: number
  user: string
  email: string
}
Run Code Online (Sandbox Code Playgroud)

要求:

users: User;

    this.userService.getUsers().subscribe(
          response => {
            if (!response) {
              console.log(Error)
            } else {
              this.users = response
            }
          })
Run Code Online (Sandbox Code Playgroud)

Http获取:

getUsers() {
        return this.service.get(this.endpoint)
        .map((response) => {
            return response;
        });
    }
Run Code Online (Sandbox Code Playgroud)

服务:

standardHeaders() {
        const headers = new HttpHeaders();
        headers.append('Content-Type', 'application/json');
        if (this.authToken) {
            headers.append('X-Authorization', this.authToken);
        }
        return …
Run Code Online (Sandbox Code Playgroud)

http typescript angular7

6
推荐指数
1
解决办法
2万
查看次数

添加自定义操作按钮-ng2-smart-table

我正在尝试向自定义操作添加按钮,但是该操作未添加新列,从而使按钮与其他按钮重叠。

码:

settings = {
    actions: {
      custom: [
        {
          name: 'Button',
          title: 'Button ',
        }
      ],
    },
    columns: {
      name: {
        title: 'Full name'
      },
      email: {
        title: 'Email'
      },
      lastLogin: {
        title: 'Last Login'
      }
    }
  };
Run Code Online (Sandbox Code Playgroud)

我需要在图像上添加一个链接,因为我在这里的声誉不高,并且图像工具对我来说是被阻止的。

反应图片:

我究竟做错了什么?

ng2-smart-table

4
推荐指数
1
解决办法
6261
查看次数

标签 统计

angular7 ×1

http ×1

ng2-smart-table ×1

typescript ×1