I've got this directive, and I'm trying to get it to reload the content it gets automatically. So far, not much luck. Care to help?
EDIT: I've tried the suggested answer but it won't work. I'm getting a $digestx10 error.
Everything works fine and is saved ok, the DOM just wont reload.
angular.module('mymodule').directive('chatContent',
["$compile",'localStorageService','loginService','peopleOnlineService',
function($compile, localStorageService, loginService, peopleOnlineService) {
var LoadData = function (data, userId) {
var template = '';
//localStorageService.IsUser(data.userId);
if(localStorageService.IsUser(userId) === true){
template = '<div class="feedItemChat"><div class="chatItem"><div class="chatMessage userChatMessage">{{content.chatMessage}}</div></div></div>';
}else{
template = '<div class="feedItemChat"><div class="chatItem"><div class="chatMessage otherChatMessage">{{content.chatMessage}}</div></div></div>';
}
return template;
};
var linker = function (scope, element) {
var data = localStorageService.LoadDataLocal(localStorageService.CheckCorrectRoom(loginService.GetUser().userId, peopleOnlineService.GetParams().userId));
scope.$watch(data, function(){
element.html(LoadData(data,scope.content.userId)).show();
$compile(element.contents())(scope);
});
};
return {
restrict: 'E',
link: linker,
scope: {
content: '='
}
};
}]);
I'm also wondering, how would one do to insert the html templates here, instead of stupidly long strings?