Skip to content

Instantly share code, notes, and snippets.

@jccrosby
Last active January 2, 2016 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jccrosby/8378692 to your computer and use it in GitHub Desktop.
Save jccrosby/8378692 to your computer and use it in GitHub Desktop.
Adding an AngularJS controller
<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