I am actually trying to show/hide a div based on user-type , suppose usertype1 will be able to see the div but usertype2 will not be able to view the div.
HTML CODE
<div class="rate animated rubberBand" ng-if="myCheck">
<input type="radio" id="starRating5" name="rate" value="5" disabled>
<label for="star5" title="text"></label>
<input type="radio" id="starRating4" name="rate" value="4" disabled>
<label for="star4" title="text"></label>
<input type="radio" id="starRating3" name="rate" value="3" disabled>
<label for="star3" title="text"></label>
<input type="radio" id="starRating2" name="rate" value="2" disabled>
<label for="star2" title="text"></label>
<input type="radio" id="starRating1" name="rate" value="1" disabled>
<label for="star1" title="text"></label>
</div>
JS CODE
if (userType === 'userType2')
{
$scope.myCheck = false;
}
else
{
$scope.myCheck = true;
}
JS CODE BLOCK which is giving me the error
if($scope.Item.starRating === 'NULL'){
$scope.Item.starRating = 0;
}
else if($scope.Item.starRating === '1'){
document.getElementById("starRating1").checked = true;
}
else if($scope.Item.starRating === '2'){
document.getElementById("starRating2").checked = true;
}
else if($scope.Item.starRating === '3'){
document.getElementById("starRating3").checked = true;
}
else if($scope.Item.starRating === '4'){
document.getElementById("starRating4").checked = true;
}
else{
document.getElementById("starRating5").checked = true;
}
THE ERROR
Cannot set property 'checked' of null
I just want to show the div for userType1 and hide for userType2. I am not using JQuery.
UPDATE
the only problem I am getting with Pengyy's solution - the problem is fixed with userType1 in which the div show but now I am facing problem with userType2 in which the div should not display. Here in userType2 inspite of myCheck being false and irrespective of whether ng-show or both ng-cloak and ng-show is used the div is displayed for few moments and then disappearing . It should not display at all for userType2
myCheckin$scopeneeds to bemycheck...its typo