angular 中的两个自定义模板,其中只有一个在工作
Two custom template in angular formly where only one of them is woking
这是代码http://jsbin.com/haluxa/6/edit
问题出在单选按钮上,它应该按如下方式工作,当我单击“是”时,必须显示带有多个复选框的其他问题。虽然它不工作第二个模板。
感谢您的帮助。
解决方法如下: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']
}]);
这是代码http://jsbin.com/haluxa/6/edit
问题出在单选按钮上,它应该按如下方式工作,当我单击“是”时,必须显示带有多个复选框的其他问题。虽然它不工作第二个模板。
感谢您的帮助。
解决方法如下: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']
}]);