I tend to use ng-show or ng-if in that case instead of playing directly with the style. This would look like (not tested):
<div class="form-group">
<label>age</label>
<input type="number" class="form-control" ng-model="age">
<p class="text-danger" ng-show="age>18">{{age}}</P
<p class="text-danger" ng-show="age<=18">You cannot register you're under 18!</p>
</div>
That would do exactly what you ask above. Since this looks more like a validation you can create your validator to be more inline with angular philosophy by implementind a directive in your module.
myModule.directive('ageCheck', function() {
return {
require: "ngModel",
link: function(scope,element,attributes,ngModel) {
ngModel.$validators.ageCheck=function(modelValue) {
return scope.age>18;
}
}
}
});
<form name="action">
<div class="form-group">
<label>age</label>
<input type="number" name="ageField" class="form-control" ng-model="age" age-check>
<p class="text-danger" ng-show="action.ageField.$error.ageCheck">You cannot register you're under 18!</p>
</div>
If you are new to Angular I strongly suggest to go through their official tutorial which is much better then others I did before. It really brings help me understand the injector/module/minification. You should also start your project using the seed.