0

I have a css class 'suggestions-list'in which I have height: initial; in my angularjs code in a condition I want to change height: inherit; how can I modify this css class using angular?

in my CSS file I have :

.suggestions-list {
    position: absolute;
    list-style-type: none;
    margin: 0 0 0 35px;
    padding: 0;
    overflow: scroll;
    height: initial;
    width: 250px;
    border-bottom: 50px;
}

and this is my HTML:

<ul class="suggestions-list" ng-show="myVar">
     <li ng-repeat="suggestion in suggestions track by $index" ng-class="{active : selectedIndex === $index}" ng-click="AssignValueAndHide($index)">{{suggestion}}</li>
</ul>
5
  • What is the problem you have now? Commented Jul 4, 2016 at 12:24
  • how can I modify this css class using angular? Commented Jul 4, 2016 at 12:40
  • You can do it like this: ng-class="{active : selectedIndex === $index}" Commented Jul 4, 2016 at 12:44
  • but how? would you please help me in writing it? Commented Jul 4, 2016 at 12:48
  • With above class active will be set if selectedIndex === $index is true. If it doesn't happen in your case, it means that selectedIndex === $index is false. Commented Jul 4, 2016 at 12:54

1 Answer 1

2

Use ng-style

<div ng-style="{height: (condition?'initial':'inherit')}"></div>
Sign up to request clarification or add additional context in comments.

5 Comments

This condition is set in my angular js code. so how can I set it from here?
@user3122648 what condition exactly do you mean? condition in ng-style can accept expression!
I', trying to do it in my Javascript code. so <div ng-style="{height:myStyle}"></div> that I want to chaneg it from Js. in which myStyle is a scope.
This is pretty bad solution. Avoid using ngStyle for such things. ngClass should be used here.
So would you pelase help me using it? becasue if I use ng-class how can I apply my css class?

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.