html - Updating Div with AngularJS -
i have div defined follows:
<button ng-repeat="message in user.messages"> <div ng-model="message" ng-show="{{message.received && !message.read}}" class="btn bg-green"></div> <div ng-model="message" ng-show="{{message.received && message.read}}" class="btn bg-green" ></div> <div ng-model="message" ng-show="{{!message.received}}" class="btn bg-amber"></div>
basically i'm changing (show/hide) icon depending on message status (received, sent, read). however, when update status of message, icons not change, though have bound ng-model. need refresh whole page icons updated.
any way can update through angular?
thank you.
ng-show doesn't need interpolated, can write "message.recieved..."
why not use ng-class this:
div ng-class="{'bg-green' : message.recieved, 'bg-amber': !meessage.recieved}"
don't bind div ng-model, doesn't make sense use 2 way data binding, when not input, , view can't update model
Comments
Post a Comment