Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Sometimes ng-click don't work in Ionic

$
0
0

Hi,

Having a quick look at your code and from reading your description it may have to do with your digest cycle. If you have an asynchronous event (promise) passing in a variable to your app you need to let AngularJS know.
This can be done by wrapping it into a
$scope.$apply(function{
whatever you want to do...
});

In your home.js you have:

$http.get('js/config.json')
.then(function(res){
baseUrl = res.data.server[res.data.mode];
});

try it with:
$http.get('js/config.json')
.then(function(res){
$scope.$apply(function{
baseUrl = res.data.server[res.data.mode];
})
});

Try and read up a bit more on promises and the digest cycle in angularJS:

http://andyshora.com/promises-angularjs-explained-as-cartoon.html
http://haroldrv.com/2015/02/using-scope-apply-in-angularjs/
http://www.sitepoint.com/understanding-angulars-apply-digest/

Also, Developer tools (inspect element) in chrome/firefox/safari can help you greatly in seeing what is going on behind the scenes. I tend to put
console.log("variable:" +variable)
in my code flow and detect the variables step by step.


Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>