I have an object that looks like this
$scope.object = {
Title: 'A title',
Status: 'Open',
Responsible: 'John Doe',
Author: 'Jane Doe',
Description: 'lorem ipsum dolor sit'
}
Now I want to see if the current user has permission to edit this item, for the user to be able to edit, the item has to
- Exist (is not null, undefiend etc)
- Responsible is equal
$scope.currentUser
- Status is equal 'Open'
if all these are true, our function should return true, I am doing it like this
$scope.isTrue = function(){
if($scope.object && $scope.object.Status == 'Open' && $scope.object.Responsible == $scope.currentUser){
return true;
}else { return false; }
}
Pretty straight forward, but are there a better way to do these kind of checks?