zoukankan      html  css  js  c++  java
  • [ngx-formly] Dynamically set Model Properties with Angular Formly Expressions

    Formly has a nice mechanism called "expression properties". These are expressions in the form of a function callback or string expression that are evaluated at runtime. In this video we're going to explore how to leverage these expressions to set values on our data model.

        {
          key: 'cityId',
          type: 'select',
          templateOptions: {
            label: 'Cities',
            options: [],
          },
          expressionProperties: {
            'templateOptions.disabled': model => !model.nationId,
            'model.cityId': '!model.nationId ? null: model.cityId',
          },
          hooks: {
            onInit: (field: FormlyFieldConfig) => {
              field.templateOptions.options = field.form.get('nationId').valueChanges.pipe(
                startWith(this.model.nationId),
                switchMap(nationId => this.dataService.getCities(nationId)),
              );
            },
          },
        },
  • 相关阅读:
    学习笔记::有上下界的网络流
    zoj2314
    bzoj3261
    bzoj 1898
    bzoj4009
    bzoj4033
    bzoj3389
    bzoj2427
    uva 11825
    交换A与B值的四种方法
  • 原文地址:https://www.cnblogs.com/Answer1215/p/12172112.html
Copyright © 2011-2022 走看看