小编Ser*_*i R的帖子

如何使用垫卡的角度材料分页?

我想使用mat-card指令来展示我的产品.角度材料文档在我看来并不彻底.我在Internet上找到了许多使用Table with dataSource的示例(示例1,示例2)

现在我获得所有产品的productList并使用ngFor进行迭代.我在页面上显示所有产品.如何将productList提供给paginator并使用已处理的数据(paginationList)进行迭代.

*component.html文件显示所有产品:

<mat-paginator #paginator 
  [length]="productList.length" 
  [pageSize]="5" 
  [pageSizeOptions]="[5, 10, 25, 100]" 
  [showFirstLastButtons]="true"
</mat-paginator>

<ng-container *ngIf="productList.length; else notHeaveProducts">
  <mat-card class="product-card" *ngFor="let product of productList">
    <mat-card-header>
      <mat-card-title>
        <h3>{{ product.title }}</h3>
      </mat-card-title>
    </mat-card-header>
    <img mat-card-image [src]="product.img_url" [alt]="product.title" [title]="product.title">
    <mat-card-content>
      <p>{{ product.description }}</p>
    </mat-card-content>
    <mat-card-actions>
      <button mat-raised-button color="accent" (click)="addItemToCard(product)">Add to card</button>
    </mat-card-actions>
  </mat-card>
</ng-container>
Run Code Online (Sandbox Code Playgroud)

*component.ts

export class ListComponent implements OnInit, OnDestroy {
  public productList: …
Run Code Online (Sandbox Code Playgroud)

pagination typescript angular-material2

7
推荐指数
2
解决办法
5546
查看次数

材料设计:如何断开浮动标签的选择?

我需要创建不带浮点标签的选择字段,但我想拥有占位符和默认值。

我阅读了文档https://material.angular.io/components/form-field/overview#floating-label并尝试自己做。

<mat-form-field [floatLabel]="never">
  <mat-select placeholder="All categories" [formControl]="catForm" multiple> //First opportunity for use placeholder
    <mat-option *ngFor="let category of categories" [value]="category.name">
      {{ category.name }}
    </mat-option>
  </mat-select>
  <!-- <mat-placeholder>All categories</mat-placeholder> -->//Second opportunity for use placeholder
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)

而且无论如何,我都会得到浮动标签。那我做错了吗?

在此处输入图片说明

material-design angular-material2

5
推荐指数
1
解决办法
1291
查看次数

无法反序列化模型实例。*来自START_ARRAY令牌\ n,位于

我进行REST服务迁移,现在尝试添加新项。

型号留言:

@Entity
@Table(name="message")
public class Message{

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID")
    private long id;
    @Column(name = "MESSAGE")
    private String message;
    @Column(name = "AUTHOR")
    private String author;
    @Column(name = "CREATED")
    @Temporal(TemporalType.DATE)
    private Date created;

    public Message() {}

    public Message(Long id, String message, String author) {
        this.id = id;
        this.message = message;
        this.author = author;
        this.created = new Date();
    }
+ getters / setters
Run Code Online (Sandbox Code Playgroud)

MessageController:

@RestController
public class MessageController {

    @Autowired
    private MessageRepository messageRepository;

    @RequestMapping(
        value = "/api/messages",
        method …
Run Code Online (Sandbox Code Playgroud)

rest json spring-boot

3
推荐指数
1
解决办法
8746
查看次数

Sequelize CLI如何从模型创建迁移?

我有两个关系一对多的模型.

我不明白如何创建迁移文件.每个模型是否都有自己的迁移文件,或者一个迁移文件可以根据模型和它们之间的关系创建多个表(例如在rails迁移中)?

我看了很多例子,包括Sequelize docs,还有模型创建及其迁移的原始示例.

//User model
module.exports = function (sequelize, Sequelize) {
    var User = sequelize.define('users', {
        id: {
            type: Sequelize.INTEGER,
            primaryKey: true,
            autoIncrement: true,
        },
        email: {
            type: Sequelize.STRING,
            allowNull: false,
            unique: true,
        },
        password: {
            type: Sequelize.STRING,
            allowNull: false,
        },
    });

    return User;
}

//Order model
module.exports = function (sequelize, Sequelize) {
    var Order = sequelize.define('orders', {
        id: {
            type: Sequelize.INTEGER,
            primaryKey: true,
            autoIncrement: true,
        },
        price: {
            type: Sequelize.INTEGER,
            allowNull: false,
        },
        totalPrice: {
            type: Sequelize.INTEGER,
            allowNull: …
Run Code Online (Sandbox Code Playgroud)

migration node.js sequelize.js

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