加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

twitter-bootstrap – 如何使用引导程序在选择框上实现onChange

发布时间:2020-12-17 21:26:06 所属栏目:安全 来源:网络整理
导读:阅读了不少帖子之后,我认为这应该有效: vm.model.myChange = function(element) { console.log(element);} ..并在vm.fields中: {"key": "transportation","type": "select","templateOptions": { "label": "How do you get around in the city","valueProp
阅读了不少帖子之后,我认为这应该有效:

vm.model.myChange = function(element) {
  console.log(element);
}

..并在vm.fields中:

{
"key": "transportation","type": "select","templateOptions": {
  "label": "How do you get around in the city","valueProp": "name","onChange": "model.myChange()",// ADDED
  "options": [{
    "name": "Car"
  },{
    "name": "Helicopter"
  }]
}

在实践中,这没有效果,即我的功能没有被调用.生成的表单也没有引用我的函数.

我找不到一个如何做到这一点的工作示例.有什么建议?

谢谢.保罗

解决方法

你可以做以下三件事中的任何一件事:

templateOptions: {
   onChange: function($viewValue,$modelValue,$scope) {
   //implement logic here
   };
}

要么

templateOptions: {
   onChange: callMe()
},controller: function($viewValue,$scope) {
    $scope.callMe = function() {
    //implement logic here
    };
}

要么

templateOptions: {
       onChange: ''
    },expressionProperties : {
       'templateOptions.onChange': function($viewValue,$scope) {
       //implement logic here
       };
   }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读