小编Tol*_*see的帖子

使用可重用组件时,Angular 7 CSS无法正常工作

我对Angular很新,来自React.js背景.

我做了一个简单的网格组件,如下所示:

grid.component.js

import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-grid',
  template: `
    <div [ngStyle]="styles()" [ngClass]="passClass">
      <ng-content></ng-content>
    </div>
  `,
  styles: [`
    div {
      display: flex;
    }
  `]
})
export class GridComponent implements OnInit {
  @Input() direction: string;
  @Input() justify: string;
  @Input() align: string;
  @Input() width: string;
  @Input() passClass: string;

  constructor() { }

  ngOnInit() {
  }

  styles() {
    return {
      'flex-direction': this.direction || 'row',
      'justify-content': this.justify || 'flex-start',
      'align-items': this.align || 'flex-start',
      ...(this.width && { width: this.width }) …
Run Code Online (Sandbox Code Playgroud)

javascript css angular angular7

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

如何使某些字段一旦保存在猫鼬中就不可更新?

我构建了一个架构,如下所示:

const UserInfoSchema = new Schema({
    email: { type: String, required: true, unique: true },
    username: { type: String, required: true, unique: true },
    userId: { type: Schema.Types.ObjectId, ref: 'User'},
    displayName: { type: String, required: true },
    profilePic: {
        filename: {type: String},
        url: {type: String}
    },
    created_at: Date,
    updated_at: Date
})
Run Code Online (Sandbox Code Playgroud)

我这里需要的是,一旦保存了电子邮件、用户名和用户 ID 等字段,就不应该修改。猫鼬中是否有针对此类功能的预构建内容?

我已经做了一些研究schema.pre('update', (next) => {}),但没有得到任何真正有用的东西/不知道是否可以使用上述功能。非常感谢有关此事的任何帮助。提前致谢。

mongoose mongodb node.js

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

标签 统计

angular ×1

angular7 ×1

css ×1

javascript ×1

mongodb ×1

mongoose ×1

node.js ×1