In time I want to convert my entire app to AngularJS, but I'll need to do it bit by bit. So for the time being, I just want to be able to make this work.
I want to be able to call the AngularJS loadData() function on a jQuery click event. But I am not sure how to do it. Any help is appreciated, thank you.
I have this jQuery code:
// When back is pressed
$('#backward').click(function() {
index--;
// Re load data
angular.element(document.getElementById('myController')).scope().loadData();
});
This AngularJS code:
.controller('MyController', function($log, $scope, myService) {
var loadData = function() {
...
};
var $scope.loadData = loadData;
And this HTML:
<body id="myController" ng-controller="MyController">
var $scope.loadData = loadData;? This is a syntax error.var $scope.loadData = loadData();and when I changed it to the one in your message - it started working!