I am having some pretty odd behaviour with some model/view data in Angular. It is two issues really. In my controller, I have the following code, which is used to update some dates in the view.
$scope.setCurrentDates = function () {
var centreIndex = $scope.state.indexOfCentreDate,
centreIndexItem = $scope.state.allDays[centreIndex],
itemLeft = $scope.state.allDays[centreIndex - 1],
itemRight = $scope.state.allDays[centreIndex + 1];
$timeout(function () {
$scope.state.currentDates.centre = $scope.state.allDays[centreIndex].isoStringdate;
$scope.state.currentDates.left = itemLeft.isoStringdate;
$scope.state.currentDates.right = itemRight.isoStringdate;
$scope.state.isUpdatingDate = false;
});
};
And then in my view, I have the following as a right/progress nav arrow:
<a>
<span class="day">{{state.currentDates.right | navDate : 'dd'}}</span>
<span class="month">{{state.currentDates.right | navDate : 'MMM'}}</span>
<span class="year">{{state.currentDates.right | navDate : 'yyyy' }}</span>
</a>
$scope.setCurrentDates in the controller gets called with every click of the above nav.
So, the first issue is as follows:
When first loading the page, no text for the dates displays. However, when I inspect the element in dev tools, and for example increase the font size from 50px to 51px, the text then displays. As I click through the nav, the dates then do not update as they should in the view. BUT when I inspect the element again, and decrease the font size back to 50px, the dates then update ??? Bizarre. This happens with any one of the CSS properties for this element I modify.
They then update as they should with each click, but then stop updating again until I modify the CSS again.
At first I though this was a scope issue but I am not so sure as the dates update correctly when logged out in the console. So it must be related to Chrome/CSS rendering.
Further bizarreness is as per the attached. You can see the dev tools DOM, representing the correct values, including within the element #console
which is represented by the black box rendered on screen.
It actually looks like this may be isolated to Chrome.
Any advice much appreciated.
Thanks,
Dave