Created
March 26, 2014 15:05
-
-
Save francolaiuppa/9785453 to your computer and use it in GitHub Desktop.
application.coffe from http://plnkr.co/edit/B5Tj9rwXaiRdLN9mwrsi?p=preview
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
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