I am new to EmberJS. I am trying to populate the record from here
The typical JSON looks as under
[
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
},
{
"userId": 1,
"id": 2,
"title": "qui est esse",
"body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
}
]
My code is as under
<!DOCTYPE html>
<html>
<head>
<title>Emberjs displaying list of items</title>
<!-- CDN's-->
<script src="http://ift.tt/1H1Z8nj"></script>
<script src="http://ift.tt/13wBVXk"></script>
<script src="http://ift.tt/1H1Z8Uo"></script>
<script src="http://ift.tt/1LNmMn9"></script>
<script src="http://ift.tt/1H1Z8nl"></script>
<script src="http://ift.tt/1e1uqGJ"></script>
</head>
<body>
<script type="text/x-handlebars">
</script>
<script type="text/x-handlebars" data-template-name="index">
<button >GetData</button>
<table>
<tr>
<td></td><td></td>
</tr>
</table>
</script>
<script type="text/javascript">
var App = Ember.Application.create()
App.IndexRoute = Ember.Route.extend({
//defining the action for the button click event
actions: {
GetUserRecords: function() {
App.userData = [];
$.ajax({
type: "get",
url: "http://ift.tt/1n31l1Y",
cache: false,
data: {},
async: false,
success: function (data) {
App.userData = data;
console.log(App.userData);
},
error: function (err) {
alert(err);
}
});
}
}
});
</script>
</body>
</html>
In the console.log(App.userData)
i am able to find the arrays
But not able to bind it to the table.
Please help.
Many thanks in advance.
Aucun commentaire:
Enregistrer un commentaire