I have conditional parameters on ui-router because I am using the same screen in different places in an app. I have to write logic to check which $stateParams
value I have assigned to paramId
. I have tried with if
and else
.
Is there a better approach to achieve this task?
$scope.challengesDTO = {
challengeTypeLkupCode: 'RA_CHLNG_TYP_PRC'
};
var paramId = $stateParams.processId ? $stateParams.processId : $stateParams.assessmentId;
if ($stateParams.processId) {
$scope.challengesDTO.challengeTypeLkupCode = 'RA_CHLNG_TYP_PRC'
} else if ($stateParams.assessmentId) {
$scope.challengesDTO.challengeTypeLkupCode = 'RA_CHLNG_TYP_RSKASES'
}