I am trying to display a html link and load it via json but I can't seem to get this to work I have tried in the below but it is displaying as text and not a link.
"test" : {
"description": "A little test '<a href=\"\">Visit Google<\/a>'"
}
I have also tried removing the \ from the end of the a
tag but this doesn't seem to work.
Loading method:
function() {
angular.module("testerMod").provider("language", function() {
"ngInject";
this.path = "/assets/locale/", this.userLanguage = "en", this.$get = function(e) {
return ["$http", "$state", "$log", "$cookies", function(t, n, i, o) {
return function(a, s) {
var r, l, c;
return l = _.find(s.locales, {
code: a
}), null == l ? (r = _.find(s.locales, {
code: o["language"]
}), null != r ? a = r.code : (c = _.find(s.locales, {
code: e.userLanguage
}), a = null != c ? c.code : _.find(s.locales, {
"default": !0
}).code), void n.go("home", {
language: a
})) : t({
method: "GET",
url: e.path + a + ".json"
}).then(function(e) {
return e.data
}, function(e) {
return i.error("Language Load Error")
})
}
}]
}(this)
})
}
using library three js
I am trying to display a html link and load it via json but I can't seem to get this to work I have tried in the below but it is displaying as text and not a link.
"test" : {
"description": "A little test '<a href=\"https://www.google.\">Visit Google<\/a>'"
}
I have also tried removing the \ from the end of the a
tag but this doesn't seem to work.
Loading method:
function() {
angular.module("testerMod").provider("language", function() {
"ngInject";
this.path = "/assets/locale/", this.userLanguage = "en", this.$get = function(e) {
return ["$http", "$state", "$log", "$cookies", function(t, n, i, o) {
return function(a, s) {
var r, l, c;
return l = _.find(s.locales, {
code: a
}), null == l ? (r = _.find(s.locales, {
code: o["language"]
}), null != r ? a = r.code : (c = _.find(s.locales, {
code: e.userLanguage
}), a = null != c ? c.code : _.find(s.locales, {
"default": !0
}).code), void n.go("home", {
language: a
})) : t({
method: "GET",
url: e.path + a + ".json"
}).then(function(e) {
return e.data
}, function(e) {
return i.error("Language Load Error")
})
}
}]
}(this)
})
}
using library three js
Share Improve this question edited Mar 14, 2019 at 12:27 Djensen 1,3631 gold badge22 silver badges33 bronze badges asked Feb 15, 2017 at 23:18 ui-unicorn.co.ukui-unicorn.co.uk 1511 gold badge5 silver badges18 bronze badges 4- 1 You'll need to show what is consuming/using this JSON or we can't take a guess why this doesn't work... JSON by itself is data, not code. – Dan Lowe Commented Feb 15, 2017 at 23:19
- Do you mean how I'm loading it or which library is using the data? – ui-unicorn.co.uk Commented Feb 15, 2017 at 23:22
- 1 Either or both - JSON without code is just text, so until we see what code is involved, it's impossible to guess what might be happening. – Dan Lowe Commented Feb 15, 2017 at 23:26
- loading method added and library used, the text loads perfectly though not the link that also es as text but with the a tags missing – ui-unicorn.co.uk Commented Feb 15, 2017 at 23:37
1 Answer
Reset to default 1maybe it is a good idea to separate view and data i have extracted properties: link source, link text this way Json would only mean to transfer data and browser or app you are using will render the view according to your apps logic.
{
"test":{
"description": "A little test ",
"link_source":"https://www.google.",
"link_text":"Visit Google"
}
}
for your version to work you may check validity of your json here if you wish https://jsonformatter.curiousconcept./ also there is another article here about Json serialization http://www.popoloproject./appendices/json-patterns.html