zoukankan      html  css  js  c++  java
  • expressionProperties属性的使用2

    import {Component} from '@angular/core';
    import {FormGroup} from '@angular/forms';
    import {FormlyFieldConfig} from '@ngx-formly/core';
    
    @Component({
      selector: 'app',
      template: `
        <form [formGroup]="form" (ngSubmit)="onSubmit(model)">
          <formly-form [form]="form" [fields]="fields" [model]="model"></formly-form>
          <button type="submit" class="btn btn-default">Submit</button>
        </form>
      `,
    })
    export class AppComponent {
      
        
      form = new FormGroup({});
      model = { email: 'email@gmail.com' };
      fields: FormlyFieldConfig[] = [
        {
          key: 'email',
          type: 'input',
          templateOptions: {
            label: 'Email address',
            placeholder: 'Enter email',
            required: true,
          },
          expressionProperties:{
              'templateOptions.disabled': model => model.itemType !== 2  // 在不等于属性为2 的情况下是 禁止的状态
          }
          
        },
         {
          key: 'email',
          type: 'select',
          templateOptions: {
            label: 'Email address',
            placeholder: 'Enter email',
            required: true,
            ngModelChange: v => {
                if(v !== 2){
                    this.form.get('itemType').patchValue('D')
                }
            }
          },
         
          
        }
      ];
    
      onSubmit() {
        console.log(this.model);
      }
    }
  • 相关阅读:
    内存队列使用Channels
    笔记20210101mongodb
    管道式的开发模式
    企业级应用架构设计
    再入历史旧坑
    路径问题 再次记录
    mongdb驱动的问题
    使用Bumblebee记录
    我和小兔子不得不说的消息v2
    流程设计器jQuery + svg/vml(Demo7
  • 原文地址:https://www.cnblogs.com/yangxuanxuan/p/13679161.html
Copyright © 2011-2022 走看看