Just need to update how you specify your ng-style:
    <div class="redDiv" ng-style="dynamicStyle">This div should become 
opaque {{result}}</div>

Updated plunk:
http://plnkr.co/edit/B9FMYZ

Gordon

On Wednesday, June 18, 2014 9:58:46 AM UTC-5, Paul Freeman wrote:
>
> I'm trying to dynamically update the value of an ng-style attribute in a 
> template 
>
> <div ng-controller="myController">
>     Current style setting : {{dynamicStyle}}
>     <div class="redDiv" ng-style="{{dynamicStyle}}">This div should become 
> opaque {{result}}</div>
>     <div ng-show="{{showBlue}}" 
> style="background-color:blue;color:white;">Other div</div>
>   </div>
>  
> The controller does something asynchronous, such as making an http 
> request.  On completion it attempts to update the dynamicStyle property on 
> the scope. 
>
> Here is a plunk demonstrating the problem :  
> http://plnkr.co/edit/Hpn00Bu4Zf0UsNrFH2qU
>  
> While I can see that the values of dynamicStyle are being reflected in the 
> content of the divs, the ng-style and ng-show directives do not seem to 
> work. 
>
> So, as I understand, an http.get() and a $timeout both call the $digest 
> cycle at the right point, and I can see that from the correct insertion of 
> dynamicStyle in the text after 'Current style setting'
>
> Surely the whole point of directives such as ng-style is that they are 
> dynamic and render DOM changes at the conclusion of a $digest cycle,  so 
> why don't I see ng-style and ng-show respond? 
>
>
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to