Provided below is my custom directive:
function ajaxMessageData()
{
var ajaxMessage = {
link: link,
restrict: "EA",
template: "success",
scope: {
success: '='
}
};
return ajaxMessage;
function link(scope, elm, attrs)
{
console.log(scope.success);
scope.$watch(attrs.success, function (newValue) {
console.log("Changed to " + newValue);
});
}
}
When using it in HTML:
<ajax-message success="vm.message"></ajax-message>
The issue I am facing is related to the scope within the directive. Initially, I can retrieve the message from vm.message
(which is a variable in my controller), but when vm.message
changes, it is not being detected within the directive. Additionally, I would like the template to only display if I receive a success message from vm.success
. Does anyone have any suggestions on how to resolve this?
Thank you.