Skip to content

Instantly share code, notes, and snippets.

@francolaiuppa
Created March 26, 2014 15:05
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 francolaiuppa/9785453 to your computer and use it in GitHub Desktop.
Save francolaiuppa/9785453 to your computer and use it in GitHub Desktop.
angular.module('application', []).directive("selectMenu", [
'$log', function(console) {
return {
scope: true,
link: function(scope, element, attrs, ctrl) {
$(element).selectmenu({
maxHeight: 150,
change: function(e, object) {
return alert(object.value);
}
});
return scope.select = element;
}
};
}
]).directive("selectOption", [
'$log', '$interpolate', function(console, interpolate) {
return {
link: function(scope, element, attrs, ctrl) {
var text;
text = interpolate($(element).text())(scope);
if (attrs.selectOption === text) {
$(element).attr("selected", "selected");
}
$(element).text(text);
return $(scope.select).selectmenu();
}
};
}
]).controller('optionsController', [
'$scope', '$log', function($scope, console) {
return $scope.options = [
{
value: "Slower",
display: "-6 Slower"
}, {
value: "Slower",
display: "-5 Slower"
}, {
value: "Slower",
display: "-4 Slower"
}, {
value: "Slow",
display: "-3 Slow"
}, {
value: "Slow",
display: "-2 Slow"
}, {
value: "Slow",
display: "-1 Slow"
}, {
value: "Medium",
display: "0 Medium"
}, {
value: "Fast",
display: "1 Fast"
}, {
value: "Fast",
display: "2 Fast"
}, {
value: "Fast",
display: "3 Fast"
}, {
value: "Faster",
display: "4 Faster"
}, {
value: "Faster",
display: "5 Faster"
}, {
value: "Faster",
display: "6 Faster"
}
];
}
]);
angular.bootstrap(document, ['application']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment