0

I have a html format like this , when sec.newValue is not empty I want it to be displayed bold and if its empty , I want to display as it is. so how can I achieve this using ng-class,i tried giving fontweight : bold but it doesn't work

<label class="message">
<span ng-repeat="sec in error" ng-class="{secNew?!sec.newValue }">{{sec. error}}</span>
</label>
.secNew {
 font-weight: bold;
}
2
  • {secNew: !sec.newValue} Commented Jul 12, 2019 at 16:05
  • i am saying about , my font-weight : bold is not reflecting Commented Jul 12, 2019 at 16:22

1 Answer 1

2

You pass an object whose key is the class to add, and the value is the condition which, when true, makes the class to actually be attached

{secNew: sec.newValue}

will apply class secNew only if sec.newValue returns something truthy.

Sign up to request clarification or add additional context in comments.

1 Comment

you must need a function to return true or false because it's needing when sec.newValue is not empty

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.