Before using AngularJS I used this code to get JSON result of function
$.ajax({
url: '@Url.Action("getGamedata", "Home")',
type: 'GET',
dataType: 'json',
cache: false,
async: false,
success: function (gameInfo) {
//alert(gameInfo.Name); //Working OK
for(var i=0;i<6;i++)
createTable(gameInfo[i]);
}
});
JSON result contain 6 items with name, genre, imageUrl and etc. Now I'm using AngularJS and I have function to build dynamic grid
function buildGridModel(tileTmpl) {
var it, results = [];
for (var j = 0; j < 6; j++) {
it = angular.extend({}, tileTmpl);
it.icon = it.icon + (j + 1);
it.title = it.title + (j + 1);
it.span = { row: 1, col: 1 };
switch (j + 1) {
case 1:
it.background = "red";
break;
case 2: it.background = "green"; break;
case 3: it.background = "darkBlue"; break;
case 4:
it.background = "blue";
break;
case 5:
it.background = "yellow";
break;
case 6: it.background = "pink"; break;
}
results.push(it);
}
return results;
}
I want to push each item title to my grid tile title.
- 1st tile title = 1st JSON item title
- 2nd tile title = 2nd JSON item title
- and etc