-
-
Save morenoh149/9424576 to your computer and use it in GitHub Desktop.
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
app.controller('HomeController', function($scope) { | |
$scope.selectedMail; | |
$scope.setSelectedMail = function(mail) { | |
$scope.selectedMail = mail; | |
}; | |
$scope.isSelected = function(mail) { | |
if($scope.selectedMail) { | |
return $scope.selectedMail === mail; | |
} | |
}; | |
}); | |
// directive that builds the email listing | |
app.directive('emailListing', function() { | |
return { | |
restrict: 'EA', // E- element A- attribute C- class M- comment | |
replace: false, // whether angular should replace the element or append | |
scope: { // may be true/false or hash. if a hash we create an 'isolate' scope | |
email: '=', // accept an object as parameter | |
action: '&', // accept a function as a parameter | |
shouldUseGravatar: '@' // accept a string as a parameter | |
}, | |
templateUrl: '/templates/emailListing.html', | |
controller: ['$scope', '$element', '$attrs', '$transclude', | |
function($scope, $element, $attrs, $transclude) { | |
$scope.handleClick = function() { | |
$scope.action({selectedMail: $scope.email}); | |
console.log($scope.isSelected); | |
}; | |
} | |
] | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment