{"action":"opened","issue":{"url":"https://api.github.com/repos/aurelia/router/issues/203","labels_url":"https://api.github.com/repos/aurelia/router/issues/203/labels{/name}","comments_url":"https://api.github.com/repos/aurelia/router/issues/203/comments","events_url":"https://api.github.com/repos/aurelia/router/issues/203/events","html_url":"https://github.com/aurelia/router/issues/203","id":103958199,"number":203,"title":"Better error message when the router is unable to find a parameter because the underlying data has not yet been loaded","user":{"login":"jeremy-holt","id":2135027,"avatar_url":"https://avatars.githubusercontent.com/u/2135027?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremy-holt","html_url":"https://github.com/jeremy-holt","followers_url":"https://api.github.com/users/jeremy-holt/followers","following_url":"https://api.github.com/users/jeremy-holt/following{/other_user}","gists_url":"https://api.github.com/users/jeremy-holt/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremy-holt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremy-holt/subscriptions","organizations_url":"https://api.github.com/users/jeremy-holt/orgs","repos_url":"https://api.github.com/users/jeremy-holt/repos","events_url":"https://api.github.com/users/jeremy-holt/events{/privacy}","received_events_url":"https://api.github.com/users/jeremy-holt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-30T22:19:37Z","updated_at":"2015-08-30T22:19:37Z","closed_at":null,"body":"My model retrieves the `arrival` object and then fills in the view.\r\n\r\nMy view has a link `<a if.bind=\"arrival.id\" class=\"btn btn-primary\" route-href=\"route:rawmaterial-new-drying; params.bind: {arrivalId:arrival.id}\">Go to dryer</a>`\r\n\r\nThe router is\r\n```\r\n{\r\n    route:\"entra-secador/novo/:arrivalId\",\r\n    moduleId:\"rawmaterial/enter-dryer\",\r\n    title:\"Alimenta o secador\",\r\n    name: \"rawmaterial-new-drying\"\r\n}\r\n```\r\n\r\nIf I don't include the `if.bind=\"arrival.id\"` I get an error:\r\n```\r\nUnhandled promise rejection Error: A value is required for route parameter 'arrivalId' in route 'rawmaterial-new-drying'.\r\n    at RouteRecognizer.generate (http://localhost:63293/jspm_packages/github/aurelia/route-recognizer@0.6.2/aurelia-route-recognizer.js:331:17)\r\n    at Router.generate (http://localhost:63293/jspm_packages/github/aurelia/router@0.11.0/aurelia-router.js:1218:34)\r\n    at http://localhost:63293/jspm_packages/github/aurelia/templating-router@0.15.0/route-href.js:33:33\r\n    at run (http://localhost:63293/jspm_packages/npm/core-js@0.9.18/modules/es6.promise.js:91:43)\r\n    at http://localhost:63293/jspm_packages/npm/core-js@0.9.18/modules/es6.promise.js:105:11\r\n    at module.exports (http://localhost:63293/jspm_packages/npm/core-js@0.9.18/modules/$.invoke.js:6:25)\r\n    at queue.(anonymous function) (http://localhost:63293/jspm_packages/npm/core-js@0.9.18/modules/$.task.js:40:9)\r\n    at Number.run (http://localhost:63293/jspm_packages/npm/core-js@0.9.18/modules/$.task.js:27:7)\r\n    at listner (http://localhost:63293/jspm_packages/npm/core-js@0.9.18/modules/$.task.js:31:9)\r\n```\r\nOn gitter I suggested that what's happening is that the router is looking to generate the route before the view is complete. Putting in the `if.bind` clearly delays the creation of the route until the page has loaded. This seems like a hack. I would expect the router to wait for everything to have loaded before trying to generate the route.\r\n\r\n@bryanrsmith replied with\r\n> that it does wait, but if you load data asynchronously there's no way for it to know. The binding expression just evaluates to undefined. route-href could ignore those errors, but they're often legitimate bugs that shouldn't fail silently. I don't think the if.bind is a hack at all.\r\n\r\nI then went on to ask for a better error message explaining that the parameter can not be found since it \"is possible that the data has not yet been loaded\".\r\n\r\nNonetheless, the behaviour is extremely inconsistent using `if.bind` to prevent the route being created before the data is loaded. There definitely seems to be some kind of timing issue between the view realizing that the link should not be created because of the `if.bind` and throwing the exception.\r\n"}}