i getting error:
assertion failed: attempted define `{{link-to "companies.show"}}` did not pass parameters required generating dynamic segments. there no route named companies.show
but have route in router.js
, working before added 2 new routes along component editing/adding records. indeed gone right - can nav directly either. think have error in different part of dominoing route.
// router.js router.map(function() { this.route('states'); this.route('companytypes'); this.route('companies', function() { this.route('show', {path: '/:company_id'}); this.route('new'); this.route('edit', {path: '/:company_id'}); }); this.route('counties', {path : '/counties/:state'}); }); // routes/companies.js export default ember.route.extend({ model() { return this.get('store').findall('company'); } }); // routes/companies/show.js export default ember.route.extend({ model(params) { return this.get('store').findrecord('company', params.company_id); } });
i passing model parameter in link-to
, show route has model hook.
ok, problem duplicated same route in router.js
// router.js this.route('companies', function() { this.route('show', {path: '/:company_id'}); this.route('new'); this.route('edit', {path: '/:company_id'}); });
both show , edit have same route: if nav http://localhost:4200/companies/1
supposed go show or edit? edit overwrites show because comes last. move show after edit:
// router.js this.route('companies', function() { this.route('new'); this.route('edit', {path: '/:company_id'}); this.route('show', {path: '/:company_id'}); });
and show starts working, edit break.
so need this:
// router.js this.route('companies', function() { this.route('new'); this.route('edit', {path: '/edit/:company_id'}); this.route('show', {path: '/:company_id'}); });
your routes now:
http://localhost:4200/companies/1 http://localhost:4200/companies/edit/1
Comments
Post a Comment