ember-router

can we view all the routes in emberjs aka something similar to what rake routes does in rails

℡╲_俬逩灬. 提交于 2019-11-30 07:04:38
As the routes file in emberjs is becoming large, I am finding it difficult to keep track of all the routes supported by emberjs app, rake routes in rails gives a list of routes in the rails app, is there a way to generate routes in similar fashion for emberjs? Currently you can access all existing routes with App.Router.router.recognizer.names or just the names using Ember.keys(App.Router.router.recognizer.names) . It's obviously not as extensive as the Rails routes but it gives a quick and dirty overview. In current versions of Ember/Ember-cli this is Object.keys(App.__container__.lookup(

Ember - Automatically redirect to firstObject

一曲冷凌霜 提交于 2019-11-30 06:25:06
问题 I'd like an Ember path /clinic/1 to automatically redirect to show the first doctor: /clinic/1/doctor/1 . Each clinic has many doctors. Unfortunately if I use this code: var doctor = clinicController.get('content.doctors.firstObject'); router.transitionTo('clinic.doctor.index', doctor); ... it does not work, as content.doctors.length is still 0 when this code runs in app_router.js . Any ideas? 回答1: You should be able to do this: App.DoctorsRoute = Ember.Route.extend({ model: function() {

Idiomatic Emberjs for nested routes but non-nested templates

一曲冷凌霜 提交于 2019-11-28 23:18:48
This is a follow-up from Understanding Ember routes . Master/detail views are great but I'm trying to have a a hierarchical URL route without nesting their templates. However, I still need access to the parent model for things like breadcrumb links and other references. So /users/1/posts should display a list of posts for user 1. And /users/1/posts/1 should display post 1 for user 1, but it shouldn't render inside the user template's {{outlet}} . Instead, it should completely replace the user template. However, I still need access to the current user in the post template so I can link back to

Ember.js sorting and filtering children of a hasMany relationship in parent route

老子叫甜甜 提交于 2019-11-28 19:21:39
Update #2 I found that when I refactored the filtering logic to take place in a compound computed property within the PostController instead of within individual routes, I was able to get it working. The solution was ultimately dependent upon a single dynamic variable set by the specific #linkTo route action that triggered filtering changes within a PostController computed property. I have a lot of work to catch up on so I can't post the solution to this specific question now, but when I can I will detail an explanation of the solution below. For now I have marked @twinturbo's answer as

Ember - Automatically redirect to firstObject

六月ゝ 毕业季﹏ 提交于 2019-11-28 18:23:37
I'd like an Ember path /clinic/1 to automatically redirect to show the first doctor: /clinic/1/doctor/1 . Each clinic has many doctors. Unfortunately if I use this code: var doctor = clinicController.get('content.doctors.firstObject'); router.transitionTo('clinic.doctor.index', doctor); ... it does not work, as content.doctors.length is still 0 when this code runs in app_router.js . Any ideas? Yehuda Katz You should be able to do this: App.DoctorsRoute = Ember.Route.extend({ model: function() { return App.Doctor.find(); }, redirect: function() { var doctor = this.modelFor('doctors').get(

How to pass API keys in environment variables to Ember CLI using process.env?

匆匆过客 提交于 2019-11-28 18:18:26
How do I pass environment variables from bashrc to Ember CLI. I imagine a situation where you need stripe api keys or pusher api-keys and you have them in your environment variables in bashrc. How do you pass the api-keys to Ember CLI. I tried using Node.js process.env in both the brocfile.js and environment.js , but when I try to access it in the Ember JS controller, the property is null. In my environment.js file I added, APP: { apiKey: process.env.KEY } In My Ember JS controller I tried accessing it with: import config from '../config/environment'; And setting the controller property lkey

What is the difference between a route and resource in New Router API?

ぃ、小莉子 提交于 2019-11-28 13:55:31
问题 I am trying to understand the difference between a Route and a Resource . The way I understand Resource helps to set sub paths of a Route object to another Route Object. But its unclear when i think of default name mapping happening for paths as well. 回答1: Please Note that from 1.11.0 onwards, this.route is only used instead of this.resource . Source: http://guides.emberjs.com/v1.11.0/routing/defining-your-routes/* Have a look at this post for a detailed explanation. This is a rough summary

Ember router: how to use transitionTo

与世无争的帅哥 提交于 2019-11-28 10:32:34
I have a link that looks like this index.html#/calendar/year/month This is how I set up my routes: App.Router.map(function() { this.resource('calendar', {path: 'calendar/:currentYear/:currentMonth'}); }); App.CalendarRoute = Ember.Route.extend({ model: function (params) { var obj = { weeks: calendar.getDaysInMonth(params.currentMonth, params.currentYear), currentMonth: params.currentMonth, currentYear: params.currentYear }; return obj; }, setUpController: function(controller, model) { controller.set('content', model); } }); I can get to it by doing this: var currentMonth = this.get('content

Nested routes rendering into same template/outlet breaks on browser back button click

人盡茶涼 提交于 2019-11-28 04:46:40
I have a nested route hierarchy that I need for my application to track user model selections. I'm trying to use a main application template and have each route render into a single outlet on that template. This works as I traverse down the route hierarchy from parent to child. However once you click the browser back button to go back up the route hierarchy the parent route renderTemplate hook doesn't fire. This results in the child being unhooked from the outlet and nothing rendered back into it. Here's an example: App = Ember.Application.create({}); App.Router.map(function(){ this.resource(

What is the complete list of expected JSON responses for DS.RESTAdapter?

拜拜、爱过 提交于 2019-11-28 02:45:41
I am attempting to write a custom express.js based server for an Ember.js app. I am getting along fairly well but I'm constantly getting stuck trying to guess what JSON responses Ember Data is expecting at a given moment. This brand new documentation is a great start http://emberjs.com/guides/models/the-rest-adapter/ but not complete enough. My stabbing in the dark has lead me to understand (Ember pre4, Ember Data 11): Context Server URL Method Req. Data Resp. Data ~~~~~~~ ~~~~~~~~~~ ~~~~~~ ~~~~~~~~~ ~~~~~~~~~~ Getting a list of all users /users GET {"users":[{...},{...}]} Getting a particular