Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hi everyone,
in my project I put 4 buttons that I want to hide at the start of experience.
So, once set up the 2 D canvas, I print all the widget property in console with: console.log($scope.app.view.Home.wdg); and all is working fine.
To achieve my porpouse I wrote this function:
$scope.initializeExperience = function() {
$scope.app.view.Home.wdg['reset']['visible']= false;
$scope.app.view.Home.wdg['rewind']['visible'] = false;
$scope.app.view.Home.wdg['play']['visible'] = false;
$scope.app.view.Home.wdg['replay']['visible']= false;
}
$scope.initializeExperience();
console.log($scope.app.view.Home.wdg);
but, in the google chrome console appears:
TypeError: Cannot set property 'visible' of undefined
at b.$scope.initializeExperience (VM10710 app.js:229)
at VM10710 app.js:235
at Object.<anonymous> (VM10710 app.js:240)
at Object.invoke (VM13 ionic.bundle.min.js:75)
at S.instance (VM13 ionic.bundle.min.js:122)
at n (VM13 ionic.bundle.min.js:98)
at g (VM13 ionic.bundle.min.js:92)
at VM13 ionic.bundle.min.js:91
at Object.x.appendViewElement (VM13 ionic.bundle.min.js:471)
at Object.render (VM13 ionic.bundle.min.js:470)
Any idea?
Hi @leonardosella ,
I think the problem is caused that the widget is not initialized yet when you call the code.
Simple call the code inside one of the events $ionic.afterEnter or modelLoad:
$scope.$on('$ionicView.afterEnter', function() {
$scope.initializeExperience();
})
further examples:
rootScope.$on('modelLoaded', function() {
$scope.inializeExperience();
});
// or jquery
angular.element(document).ready(function () {$scope.inializeExperience();});