I am getting some response from my service. The response is in the form of
"My data <my-tag>Click me</my-tag>".
The response contains the tag "my-tag". I want to write a directive which would manipulate the content "Click me" within the tag whenever the response is rendered. The content within the custom tag should be converted into a hyperlink. How can I do this? Here is my sample code.
I have myService.js
Service.js
(function() {
function myService() {
this.getData = function(question,questionType) {
anotherService.getList(function(data, status) {
//Here data.text = "<my-tag>Click me</my-tag>"
document.getElementById("additionalData").innerHTML + data.text;
});
}
}
app.addService(app.config.modules.MY_MODULE, "myService", myService);
}());
Directive.js
(function() {
app.directive('myTag', function () {
debugger;
return {
link: function ($scope, element, attrs) {
debugger;
//Convert the text "Click me" into hyperlink
}
};
});
}());
myHtml.html
<html ng-app = "myApp">
<head>
<script>
app.inject(app.config.modules.MY_MODULE, "myService", function(instance) {
myService = instance;
console.log("myService dependency injected successfully.");
});
</script>
</head>
<body ng-controller="myCtrl">
<div>
<img id="getList" onclick="myService.getData()">
</div>
</body>
</html>