Hey there! I'm facing an issue with my web application that I built using AngularJS and Spring. This platform allows users to post messages, and I've written the following code in my Angular controller.
<div class="row" ng-repeat="message in messages">
<div class="col-md-4 mb" style="margin-left: 40px;">
<div class="darkblue-panel pn">
<div class="darkblue-header">
<h5>{{messages.message}}</h5>
</div>
{{messages.creator}} {{messages.date | date:'dd.MM.yy'}}
<br/>
<div ng-show="'{{messages.creator}}'=='{{settingsAccount.login}}'">
<button type="submit"
ng-click="update(messages.id)"
class="btn btn-default">
<span class="glyphicon glyphicon-pencil"></span> Edit
</button>
<button type="submit"
ng-click="delete(messages.id)"
class="btn btn-danger">
<span class="glyphicon glyphicon-remove-circle"></span> Delete
</button>
</div>
</div>
</div>
</div>
I have noticed that the ng-show line is responsible for displaying the edit and delete buttons only to the creator of a message. Everything works perfectly until I refresh the page. After refreshing, the message is displayed but the buttons disappear.
Even though the values (messages.creator and settingsAccount.login) remain the same, it seems like the ng-show condition is not being checked after the page refresh. Strangely, when I paste a new message, the condition is evaluated and I can edit both the old and new messages.
Can someone help me figure out how to solve this problem? Why does the ng-show condition fail to work after a page refresh? Is the ng-repeat executed differently after a refresh?