I'm trying to achieve a series of nested SELECT with Formly. My options look like this :
$scope.productsList = [{
name : 'product1',
options : [
name : 'option1Product1',
name : 'option2Product1'
]
},
{
name : 'product2',
options : [
name : 'option1Product2',
name : 'option2Product2'
]
}
]
My first select is easy :
{
type: 'select',
key: "product",
templateOptions: {
label: 'Product',
options: $scope.productsList,
"valueProp": "name",
"labelProp": "name"
}
}
But my second select doesn't get its options updated when the users changes the selected product :
{
type: 'select',
key: "option",
templateOptions: {
label: 'option',
options: $scope.productsList[$scope.model.product].options,
"valueProp": "name",
"labelProp": "name"
}
}
Any idea of how to achieve this ?
You could use a formly built-in watcher, or a regular
$scope.$watch
inside the controller.You might consider checking out the the latter in this cascaded select example.
Applied to your model:
JSBin: http://jsbin.com/laguhu/1/