I am accessing dom elements in my controller function. Since my controller run before my entire dom has rendered, elements like $(".memos .inner")
does not register. So I am using $(window).load which works great.
My question: What's the most appropriate way to run a function in angular that uses dom elements? I know it's looked down upon to use jQuery in Angular. So whats the angular way to do this? $(".memos .inner")
is an element already defined in my view.
app.controller('useSpreadsheetData', function(){
$(window).load(function() {
var slideIndex = 0;
var slideCount = $(".memos .inner").children().length;
var slideWidth = 100/slideCount;
$(".memos .inner").css({width:slideCount * 100 + '%'});
var holderWidth = slideCount*100;
var increment = holderWidth/slideCount;
//set the left position for each slide
$(".memos .inner").find(".section").each(function(slide) {
var left_pos = (slideWidth * slide) + '%';
$(this).css({"left":left_pos});
$(this).css({"width": slideWidth + '%'});
});
});
});