I saw some similiar posts at forum but didn't find solition to my problem. Maybe it's because I'm new to js/angular and that stuff. Here's the thing:
Perfect picture: I click button data (some text / numbers) from server are updated and displayed.
My problem is - I get the data only once. Later some other function from jquery.js is called instead of mine.
if ( !(eventHandle = elemData.handle) ) {
eventHandle = elemData.handle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded
return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
undefined;
};
my code:
controllers.js:
myApp.controller('ajaxController', function($scope, $http, $log){
$scope.ajaxData={};
$scope.ajaxData.doClick = function(item, event){
$http({method: 'GET', url: 'temp/temp.json', params: { 'foobar': new Date().getTime() } }).
success(function(data, status, headers, config) {
$log.debug(data);
$scope.ajaxData = data;
}).
error(function(data, status, headers, config) {
$log.debug("not good");
});
index.html:
<div class="container" ng-controller="ajaxController"> (...)
<button ng-click="ajaxData.doClick(item, $event)">Send Request</button>
percentage: {{$scope.ajaxData.data.cpu}}</br>
usage: {{$scope.ajaxData.total}}</br>
idle: {{$scope.ajaxData.idle}}</br>
I can see in chrome console that first request is done and it succeed, later code mentioned above is executed instead and i get no data.