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
MultipleModelService.watchMultiple({ | |
models: [ | |
{ method: ReserveWishListModelProvider.getAll, as: 'reserveWishListItems'}, | |
{ method: ReserveItemsModelProvider.getAll, as: 'reserveListItems'} | |
], | |
transformAs: 'fullReserveList', | |
// Concatenate wish list items and reserve items to create the full reserve wish list | |
transform: function buildReserveList(reserveWishItems, reserveItems) { | |
reserveWishItems = _.sortBy(reserveWishItems, function (i) { | |
return i.description.toLowerCase(); |
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
// | |
// Problem: In Angular, you're using directives in the HTML to reference properties on the scope, | |
// but you end up with super long expressions in your html like ... | |
// | |
// ng-if="myCity.publicZoo.myEscapedAnimal.type === animals.mammals.primates.orangutan" | |
// | |
// and you end up exposing constants to the scope so you can do those checks | |
// | |
// $scope.animals = Animals | |
// |
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
// Route multiple form elements to a single method to handle key presses in Angular | |
//ng-keypress="checkKey($event)" | |
$scope.checkKey = function(e){ | |
if(e.charCode === 13){ // 13 = Enter | |
switch(e.currentTarget.name){ | |
case 'elementName': | |
$scope.doThing(); | |
break; | |
case 'elementTwo': |
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
myApp.directive('no-input', function() { | |
return { | |
restrict: 'A', | |
replace: false, | |
link: function(scope, el) { | |
el.on('keydown', function(e){ | |
if(e.keyCode === 8){ | |
el.val(''); | |
el.trigger('change'); | |
} else { |
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
$.monthsToYears = function(months){ | |
var val; | |
if(months < 12) { | |
val = months + ' month'; | |
if(months > 1 || months === 0){ | |
val += 's'; | |
} | |
} else { | |
var yrs = Math.floor(months/12); | |
var mo = months%12; |