cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Problem with visible property

leonardosella
12-Amethyst

Problem with visible property

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?

1 REPLY 1

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();});

 

Top Tags