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.

  1. ng-show doesn't need interpolated, can write "message.recieved..."

  2. 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

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -