两个自定义模板,角度形式,其中只有一个是woking

时间:2015-06-03 14:59:42

标签: angular-formly

这是代码http://jsbin.com/haluxa/6/edit

问题在于单选按钮,它应该如下工作,而我点击是,必须显示多个复选框的其他问题。虽然它不是第二个模板。

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

以下是解决方案:http://jsbin.com/miroge/edit?html,js,output

问题是你用两个对象调用setType,而不是两个对象的数组。你在做什么:

formlyConfigProvider.setType({
  name: 'multi-checkbox',
  templateUrl: 'multi-checkbox-template.html',
  wrapper: ['bootstrapLabel', 'bootstrapHasError']
},{
  name: 'well-multi-checkbox',
  templateUrl: 'well-multi-checkbox-template.html',
  wrapper: ['bootstrapLabel', 'bootstrapHasError']
});

你应该做什么:

formlyConfigProvider.setType([{
  name: 'multi-checkbox',
  templateUrl: 'multi-checkbox-template.html',
  wrapper: ['bootstrapLabel', 'bootstrapHasError']
},{
  name: 'well-multi-checkbox',
  templateUrl: 'well-multi-checkbox-template.html',
  wrapper: ['bootstrapLabel', 'bootstrapHasError']
}]);