也許這是一個好主意,單獨的視圖和數據我已經提取的屬性
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)
})
}
:鏈接源,鏈接文本,這樣的Json只會意味着傳輸數據和瀏覽器或應用程序將根據您的應用程序邏輯渲染視圖。
{
"test":{
"description": "A little test ",
"link_source":"https://www.google.com",
"link_text":"Visit Google"
}
}
爲您的版本工作,如果你想https://jsonformatter.curiousconcept.com/ 也有另一篇文章在這裏關於JSON序列化可以在此處檢查您的JSON的有效性http://www.popoloproject.com/appendices/json-patterns.html
你需要證明什麼是消費/使用此JSON或我們不能猜測爲什麼這不起作用...... JSON本身是數據,而不是代碼。 –
你是指我如何加載它或哪個庫正在使用這些數據? –
其中之一或兩者 - 無代碼的JSON只是文本,所以直到我們看到涉及的代碼時,不可能猜測可能發生了什麼。 –