1

I am using below code as a validation message. i am trying to hide my validation message if its success message. please check my code

    <div uib-alert ng-repeat="alert in alerts"  ng-class="'alert-' + (alert.type || 'info')" dismiss-on-timeout="{{alert.type == success ? '5000' : ''}}"
    close="alerts.splice(index, 1)">
   {{alert.msg}}

alert. type can be 'success or error'. i need to hide this only if, 'alert.type= success'. i tried. but not working. how i add condition. thanks

5
  • Take a look on this question Commented Apr 20, 2020 at 7:41
  • this is not ok with my problem. ' dismiss-on-timeout' should work only success messages, (alert.type==success) Commented Apr 20, 2020 at 7:44
  • Is success a variable in alert.type == success ? '5000' : ''? Commented Apr 20, 2020 at 7:55
  • alert.type variable can be 'success' or 'error' Commented Apr 20, 2020 at 7:57
  • i need to hide my div , only alert.type = success Commented Apr 20, 2020 at 7:57

1 Answer 1

1

You need to use the string success and 5000 as a number, also the else condition would be none instead of ''. Combining all these, you will need:

dismiss-on-timeout="{{ alert.type == 'success' ? 5000 : 'none' }}"

Plunkr example

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

Comments

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.