Have looked for an answer here but couldn't find one. May just be searching for the wrong thing!
I am trying to run some jquery after loading json data via angulars http.get
. The problem is I can't get the jquery to work and wondered if anybody knew why.
The request works fine and loads the data, it is just the $('.verb').fadeIn(600);
that doesn't work. The console.log
works fine.
I have a suspicion it is something to do with the jquery trying to run before the element is loaded into the DOM, but wherever I put the jquery it doesn't work.
The code I have is:
(function () {
var app = angular.module('verbsApp', []);
app.controller("PostsCtrl", function ($scope, $http) {
$http.get('data/verbData.min.json').
success(function (verbData) {
$('.verb').fadeIn(600);
console.log('success');
$scope.passedData = verbData.data;
console.log($scope.passedData);
}).
error(function (verbData) {
// log error
console.log('error');
});
});
})();