I“m learning ember and have troubles with REST api. I“ve read docs, but I just can't understand, how it works. It’s really a problem, and I’d like to ask experiences people, and I would be very grateful for any help. I just need to understand the principle of how it works. In China, when kung-fu masters teach their students, they say "do as I do". So, show me please how you do it! So, we have two rouset in Laravel backend, that return JSON. Here is response of index (/) route:
<code>
{
"responce":[
{
"id":0,
"title":"main",
"content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae, aliquam."
},
{
"id":1,
"name":"about",
"content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Provident, obcaecati? Accusantium ex dolorum voluptate deleniti?"
},
{
"id":2,
"name":"contacts",
"content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptates voluptatibus exercitationem molestias rem."
}
]
}
</code>
And here is response of posts (/posts) route:
<code>
{
"posts":[
{
"id":0,
"name":"First",
"content": "Lorem ipsum dolor sit amet consectetur adipisicing."
},
{
"id":1,
"name":"Second",
"content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto quas quia distinctio ex consequuntur."
},
{
"id":2,
"name":"Third",
"content": "Lorem ipsum dolor sit amet consectetur adipisicing elit. Ullam, similique. Voluptatum, libero sequi."
}
]
}
</code>
In Ember we have routes “index” and “posts”. I suppose there must be some kind of loop that processes the received data and outputs it.
The result on the index page should look something like this:
<pre>
<!--Index page in Ember-->
<h3>main</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vitae, aliquam.</p>
<h3>about</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Provident, obcaecati? Accusantium ex dolorum voluptate deleniti?</p>
<h3>contacts</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptates voluptatibus exercitationem molestias rem.</p>
</pre>
And on the posts client page:
<pre>
<!--Posts page in Ember-->
<h3>First</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing.</p>
<h3>Second</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto quas quia distinctio ex consequuntur.</p>
<h3>Third</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ullam, similique. Voluptatum, libero sequi.</p>
</pre>
What Ember elements should be involved in this, how it all communicates and works? I really have not found any demonstrative examples on the Internet that show the whole chain. If I saw all this, I would immediately understand. Great thanks in advance! (excuse me my french)
Aucun commentaire:
Enregistrer un commentaire