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
Post a Comment