0

I am not sure what will be best approach to handle the situation .

my angular js code look like:
<span class="something" ng-hide="onsomecondition">
   {{value}}
</span>

.something{ text-align:left; padding:10px;}

Problem: in my dom val get updated but not able to display correct value in the screen .

but if i remove the class attribute it seems fine but than my styles are gone . Is there a way to make sure i can keep style and value updated correctly?

thank! in advance for any advice.

user429035
  • 411
  • 1
  • 5
  • 14

2 Answers2

0

You can make use of ng-class in this case

<span ng-class="something" ng-hide="onsomecondition">
   {{value}}
</span>
V31
  • 7,626
  • 3
  • 26
  • 44
  • it works over here http://jsfiddle.net/y8uyufag/1/ might be some other issue can you show your controller and check if thr is any console error – V31 Aug 23 '14 at 02:21
  • well seems like in your code also styles were not applied if you inspect. i just added background-color attribute and it does not seems like applying the style http://jsfiddle.net/paulL/y8uyufag/2/ – user429035 Aug 23 '14 at 02:54
  • anyways find out the issue it should be ng-class="'something'" instead of ng-class="something" . need to pass a string. modify your code above an di will accept your answer ... thanks! – user429035 Aug 23 '14 at 02:57
0

this problem can be solve by using ng-bind . I am facing the same problem answered in this question : AngularJS : Why ng-bind is better than {{}} in angular?

<span ng-bind="value" ng-hide="onsomecondition">
</span>
Community
  • 1
  • 1
user429035
  • 411
  • 1
  • 5
  • 14