handlebars.js - Ember.JS - Return & Display Parameter from URL -


i'm building first ember app , i'm trying pass , display parameter in view, grabbing url...

so if went index.html#/quotes/5
want view display "test: 5"

app.js:

app.router.map(function(){   this.resource('quote', function(){     this.resource('quotenumber', {path: ':quote_id'});   }); });  app.quotenumberroute = ember.route.extend({     model: function(params){         return(params.quote_id);     } }); 

html:

  <script type="text/x-handlebars" id="quote">       test: {{outlet}}   </script>    <script type="text/x-handlebars" id="quotenumber">       {{quote_id}}   </script> 

so if go "example.com/index.html#/quote/3"
i'd want view display "test: 3",
if went "example.com/index.html#/quote/10"
i'd want view display "test: 10"

but right displays nothing, , can't find what's missing.

the main issue use of quote_id in template. inside template telling handlebars grab property quote_id off model provided template.

dissecting model associated route you'll see model quote_id value, 5 or 7 etc. model fit template { quote_id: 5 } way ember/handlebars can search property quote_id on model , bind value.

here's example of you're trying (note, have returned params object itself).

http://emberjs.jsbin.com/oxidivu/309/edit

i added convenient link, type in url , desiring, http://emberjs.jsbin.com/oxidivu/309#/quote/123123

ps. didn't show, nor mention, need application template. root of application, if plan on having nothing in it, can put {{outlet}}

ex.

<script type="text/x-handlebars" data-template-name="application">   {{outlet}} </script> 

or short

<script type="text/x-handlebars">   {{outlet}} </script> 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -