Created
January 12, 2014 00:07
-
-
Save jccrosby/8378676 to your computer and use it in GitHub Desktop.
Creating a module and 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-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