angularjs - ng-if condition with model which is updated using ajax -


i have model in controller updated via asynchronous call through $http. , using flag check whether model defined or not.

 function mycontroller(modelservice){        var vm = this;        vm.mymodel = modelservice.data; // modelservice.data updated asynchronously later        vm.showdetails = typeof vm.mymodel !== 'undefined';   //flag check whether model defined or not  } 

html,

 <div ng-if='mycontroller.showdetails'>            ...  </div> 

currently div not shown after mymodel populated proper data later. please let me know i'm going wrong?

$http return promise can use like

modelservice.data()   .then(function(response){       vm.showdetails = true;    }) 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -