Skip to content

Instantly share code, notes, and snippets.

@markalanevans
Created April 5, 2013 18:12
Show Gist options
  • Select an option

  • Save markalanevans/5321395 to your computer and use it in GitHub Desktop.

Select an option

Save markalanevans/5321395 to your computer and use it in GitHub Desktop.
#angularjs #ngClass How to use an ngClass expression to set a custom class if a $scope.value is true. For this example, when the validations.shipping_cost_per_item is set, the "error" class will be applied to the outer div.
<div ng-class="{error: validations.shipping_cost_per_item}" class="control-group">
<label class="control-label">Shipping Cost Per Item</label>
<div class="controls">
<input class="input-small" type="text" ng-model="merchant.shipping_cost_per_item"/>
<span class="help-inline">{{validations.shipping_cost_per_item}}</span>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment