0

I got this fiddle http://jsfiddle.net/L60L3gv9/9/ where when I match an item in the table, it highlights it with :

ng-class="{show: test==x.Country}"

Whereas I'm expecting something like in this fiddle :

http://jsfiddle.net/nmcsr5x9/1/

but with the last fiddle I have to declare other variables in the scope.

Any ideas why the first fiddle is acting like that ?

4
  • Can you please tell me which variable you are talking about? as I'm seeing both 'test' in first and 'myVar' in second in the scope. Commented Feb 8, 2016 at 13:17
  • in the 2nd fiddle, I have myVar and myVar2 Commented Feb 8, 2016 at 13:20
  • Ok, so both myVar,myVar2 in second is in Scope and test in first is in scope so what exactly you wanted to know? both are same. Commented Feb 8, 2016 at 13:23
  • i'm not fighting against a javascript issue but rather a css issue that I don't get Commented Feb 8, 2016 at 13:26

2 Answers 2

3

It's because you use .show class. This will display your table-row as block by bootstrap.

You have two options:

1. use another class name, like .highlight

2. add display: table-row !important; to .show

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

Comments

1

In the former jsfiddle, in <tr ng-repeat="x in names |filter:match" ng-class="{show: test==x.Country}"> class with name show is getting applied. The show has a CSS definition in bootstrap as display: block !important; which makes tr to follow block level element strictly. So it behaves weirdly in the first example.

Whereas in the latter no show class has been made use of. Instead code: ng-class="{ 'red-background' : x.Name==myVar2 }"> with ng-class having custom css class red-background has been used.

So it behaves good in the second example.

1 Comment

Do you have an idea of fixing it using the first fiddle ?

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.