Hi,
I have set up a directive to display user status like so:
appDirectives.directive('userstatus', function($rootScope, $filter) {
return {
restrict: 'A',
replace: true,
link: function(scope, element, attributes) {
function updateStatus() {
var inStatus = scope.user.inStatus == '100' ? 'OUT': 'IN';
var clockTime = $filter('date')(scope.user.clockTime, 'HH:mm dd/MM/yyyy');
scope.userStatus = 'You are currently clocked '+inStatus+' at '+clockTime;
}
$rootScope.$on('statusupdate', function() {
updateStatus();
});
updateStatus();
},
template: '<div class="card">\
<div class="item item-text-wrap">\
<p>Hello, {{user.Emp}}</p>\
<p>{{userStatus}}</p>\
</div>\
</div>'
}
});
So all I’m doing is creating a sentence which is then used in the directive template, and gets updated at another point in my app.
On Android & browsers this works fine, but in ios, the content duplicates. E.g. It says ‘You are currently clocked IN at 11.09 24/04/2015’, and then when the status is updated, it appends to the current sentence like this: ‘You are currently clocked IN at 11.09 24/04/2015You are currently clocked OUT at 11.10 24/04/2015’
Any ideas where I’m going wrong?
Thanks for any help