Angular 1.4 BETA Text Binding bug
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<body ng-app="myApp">
<div ng-controller="imageController">
<!-- AJAX loader -->
<div id="circularG" ng-show='showAjaxLoader'>
<div id="circularG_1" class="circularG"></div>
<div id="circularG_2" class="circularG"></div>
<div id="circularG_3" class="circularG"></div>
<div id="circularG_4" class="circularG"></div>
<div id="circularG_5" class="circularG"></div>
<div id="circularG_6" class="circularG"></div>
<div id="circularG_7" class="circularG"></div>
<div id="circularG_8" class="circularG"></div>
</div>
<!-- Next/Previous buttons -->
<button id='previous' ng-click='getPrev()' ng-init='showPrev=false' ng-show='showPrev'>Prev</button>
<button id='next' ng-click='getNext()' ng-show='showNext'>Next</button>
<!-- image -->
<img src={{url}} orientable />
</div>
</body>
CSS
img{
width: 100%;
}
button{
position: fixed;
top: calc(50% - 17px);
font-size: 25px;
}
#previous{
left: 0px;
}
#next{
right: 0px;
}
/* AJAX loader */
#circularG{
position:relative;
width:58px;
height:58px;
margin:...
JavaScript
angular
.module('myApp', [])
.directive('orientable', function () {
return {
scope: false,
link: function($scope, element, attrs) {
$scope.$watch("url", function(newValue){
element.bind("load" , function(e){
// success, "onload" catched
// now we can do specific stuff:
// $('#circularG').hide();
$scope.$apply(function(){
$scope.showAjaxLoader = false;
});
// angular.element('#circularG').hide();
});
});
}
}
})
.controller("imageController", ['$scope', function ($scope) {
var imageArray = [
'https://s3-us-west-2.amazonaws.com/page-sorter/lymphoma.ca1441745287809.jpeg',
'https://s3-us-west-2.amazonaws.com/page-sorter/luminosawellness.com1441745729564.jpeg',
'https://s3-us-west-2.amazonaws.com/page-sorter/louisianalifescience.com1441745729564.jpeg'
];
var index = 0;
$scope.showAjaxLoader = true;
$scope.url = imageArray[index];
if(imageArray.length > 0){
$scope.showNext = true;
}
$scope.getPrev = function(){
$scope.showAjaxLoader = true;
index--;
$scope.url = imageArray[index];
if(index === 0){
$scope.showPrev = false;
}
$scope.showNext = true;
};
$scope.getNext = function(){
$scope.showAjaxLoader = true;
index++;
$scope.url = imageArray[index];
if(index === imageArray.length-1){
$scope.showNext = false;
}
$scope.showPrev = true;
};
}]);