user2010243 user2010243 - 6 months ago 38
AngularJS Question

check the expression value in angular

I have a div which needs to be displayed if one of the radio button is selected else hidden. What i am trying is :

<body ng-controller="MainCtrl">
<form name="myForm" ng-submit="submitForm()">
<label><input type="radio" name="test" ng-model="radioValue" value="1"/> One</label>
<label><input type="radio" name="test" ng-model="radioValue" value="2"/> Two</label>
<label><input type="radio" name="test" ng-model="radioValue" value="3"/> Three</label>
<div>currently selected: {{radioValue}}</div>
<div ng-show = "{{radioValue}}=='1'">
<p> Metric Test values</p>
<b> Src: Value1 </b>
<b> Metric1: Value2 </b>
<b> Density: Value3 </b>
</div>
<button type="submit">Submit</button>
</form>
</body>


However i am not able to display the div irrespective of the combobox selected or not

Answer

Remove the {{}} for radioValue for ng-show like below

<div ng-show = "radioValue=='1'">