I have added three models widgets & changed the studio-id as frame, cab & tires. I also added a button with a function name as hideModels(). I tried to hide all the models at once by clicking the button. I used for loop in the code as attached here. But it didn't work. I hope the syntax is correct. The error is visible property is not defined. What can I do to loop all the models to hide.
$scope.hideModels = function(){ var models = ["frame","tires","cab"]; for (i = 0 ; i <= models.length ; i++){ $scope.app.view.Main.wdg[models[i]].visible = false; } }
Thanks!!
Hi @venkatraj,
I think it should be
instead of
$scope.app.view.Main.wdg[models[i]].visible = false; >> $scope.app.view.wdg[models[i]].visible = false;
but if this does not help then here some additional suggestions:
$scope.hideModels = function(){ var models = ["frame","tires","cab"]; for (i = 0 ; i <= models.length ; i++){ $scope.app.view.wdg[models[i]]['forceHidden'] = true; $scope.app.view.wdg[models[i]].visible = false;
// or
$scope.setWidgetProp(models[i], 'visible', false);
$scope.app.view.wdg[models[i]]['forceHidden'] = true;
$scope.$applyAsync(); } }
- If it not work then try using the function instead of the direct setting
- as second option use additional $scope.$applyAsync(); call
- the last strong option is to set forceHidden property - also via setWidgetProp function.
Hi @RolandRaytchev,
It didn't work. What worked was, little correction in for loop. When wrote the for loop like below, it worked perfectly. Instead of '<=' just '<' did the work. When we use <= there was an undefined element at the end of loop, which caused the code not functional
var models = ["frame","tires","cab"]; for (i = 0 ; i < models.length ; i++){
$scope.app.view.Main.wdg[models[i]].visible = false;
}
Thanks a lot for your help!