码迷,mamicode.com
首页 > Web开发 > 详细

[AngularJS] angular-formly: expressionProperties

时间:2015-05-07 06:27:51      阅读:445      评论:0      收藏:0      [点我收藏+]

标签:

angular-formly provides a very simple API to dynamically change properties of your field (like disabled, hidden, and required) using the powerful expressionProperties property on your field.

 

(function() {

    ‘use strict‘;

    var app = angular.module(‘formlyExample‘, [‘formly‘, ‘formlyBootstrap‘]);

    app.controller(‘MainCtrl‘, function MainCtrl() {
        var vm = this;
        vm.model = {};
        vm.fields = [
            {
                type: ‘checkbox‘,
                key: "control",
                templateOptions: {
                    label: ‘Click to show‘
                }
            },
            {
                type: ‘input‘,
                key: "nothing",
                templateOptions: {
                    label: "Show when checkbox checked"
                },
                expressionProperties: {
                    hide: function($viewValue, $modelValue, scope) {
                        console.log(scope.model.control);
                        return !scope.model.control;
                    }
                }
            }
        ];
    });

})();

 

[AngularJS] angular-formly: expressionProperties

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/4483749.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!