ember.js - How to get currentPath and dynamic segment in Controller -


is there 'ember' way current dynamic segment? available in route via params, how access them arraycontrollers ?

any solution this.get('controllers.application.currentpath') ? of course window.location.hash there, ember way more efficient.

[update]

basically doing (its photo gallery).

there 1 model (photo). 1 sample:

{   id: 1,   name: 'brad-pitt',   date_added: 'sat apr 05 2014 23:04:35 gmt+0530 (ist)',   link: 'example.com',   image: 'http://www.somewebsite.com/image.jpg',   rank: 20 } 

routes:

 app.router.map(function(){    this.route('index', {path: '/'});      this.route('photos', {path: ':name'});   }) 

/ shows models, sorted rank.

/brad-pitt again, shows all models, filters ones have name = 'brad-pitt'

/brad-pitt?p=1 shows all models, filters name = "brad-pitt" , highlights 1 id 1 (masonry m2 specific).

controller:

app.photoscontroller = ember.arraycontroller.extend({   needs: ['application'],   itemcontroller: 'photo',   queryparams: ['p'],   p: null,    pictures: function() {     var p = this.get('p');     var pics = this.get('model');      // console.log(this.get('controllers.application.currentroutename'));      if(p) {       return pics.filterproperty('id', p);     } else {       return pics.filterproperty('name', 'some-one'); // <- needs dynamic     }   }.property('p', 'model') });   app.photocontroller = ember.objectcontroller.extend({   link_out: function() {     return 'http://' + this.get('link')   }.property() }); 


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -

PHPMotion implementation - URL based videos (Hosted on separate location) -