Last active
January 2, 2016 23:49
-
-
Save jccrosby/8378692 to your computer and use it in GitHub Desktop.
Adding an AngularJS controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-controller="SliderCtrl"> | |
<div id="slider01"></div> | |
<div id="view"> | |
<h1>I'm The View</h1> | |
<img id="image01" src="images/view-two.jpg" alt="View"> | |
</div> | |
</div> | |
<script> | |
function SliderCtrl($scope) { | |
var DEFAULT_WIDTH = 500; | |
var DEFAULT_HEIGHT = 375; | |
$('#slider01').slider({ | |
value: 50, | |
slide: function(event, ui) { | |
var scale = $('#slider01').slider('value')/100; | |
var newWidth = DEFAULT_WIDTH * scale; | |
var newHeight = DEFAULT_HEIGHT * scale; | |
$('#image01').width(newWidth); | |
$('#image01').height(newHeight); | |
} | |
}); | |
$('#image01').width(DEFAULT_WIDTH*.5); | |
$('#image01').height(DEFAULT_HEIGHT*.5); | |
} | |
SliderCtrl.$inject = ['$scope']; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment