I'm pretty new to AngularJS so hopefully this is easy, I have the following HTML where I am trying to check if a current page is equal to zero and if so, I changed the class name of the tag to disabled. (currentPage is defined to be zero in my controller)
<script>
if ('{{currentPage}}' == 0) {
document.getElementById("prev").className = "disabled";
}
if ('{{currentPage}}' >= '{{eventslist}}'.length / '{{pageSize}}' - 1) {
document.getElementById("next").className = "disabled";
}
</script>
However, whenever I try to do a check like this, it never sees currentPage as zero. So then I added an else statement just to see what currentPage actually is.
<script>
if ('{{currentPage}}' == 0) {
document.getElementById("prev").className = "disabled";
} else {
document.getElementById("prev").innerHTML = "{{currentPage}}";
}
if ('{{currentPage}}' >= '{{eventslist}}'.length / '{{pageSize}}' - 1) {
document.getElementById("next").className = "disabled";
}
</script>
After doing this, sure enough, it does come back as zero. Any ideas why the if statement fails on something so simple? Thanks in advanced!
$scopefor working with local variables?<script>block. The correct way to do this would be to put all this logic in an Angular directive; then you won't need to muck about with direct DOM manipulation like innerHTML.