Skip to content

Instantly share code, notes, and snippets.

@jccrosby
Created January 12, 2014 00:07
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/8378676 to your computer and use it in GitHub Desktop.
Save jccrosby/8378676 to your computer and use it in GitHub Desktop.
Creating a module and controller
<div ng-app="SliderModuleApp" class="sample">
<div ng-controller="SliderModuleCtrl">
<div id="slider02"></div>
<div id="view02">
<h1>I'm The View</h1>
<img id="image02" src="images/view-two.jpg" alt="View">
</div>
</div>
<script>
var SliderModuleApp = angular.module('SliderModuleApp', [function(){
}]);
var SliderModuleCtrl = SliderModuleApp.controller('SliderModuleCtrl', ['$scope',
function($scope){
var DEFAULT_WIDTH = 500;
var DEFAULT_HEIGHT = 375;
$('#slider02').slider({
value: 50,
slide: function(event, ui) {
var scale = $('#slider02').slider('value')/100;
var newWidth = DEFAULT_WIDTH * scale;
var newHeight = DEFAULT_HEIGHT * scale;
$('#image02').width(newWidth);
$('#image02').height(newHeight);
}
});
$('#image02').width(DEFAULT_WIDTH*.5);
$('#image02').height(DEFAULT_HEIGHT*.5);
}]);
</script>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment