EmberJS - sharing a controller / template for different routes

后端 未结 2 487
Happy的楠姐
Happy的楠姐 2020-12-28 14:23

I have a very simple CRUD application that allows for creating new objects as well as editing them.

The template used for adding a record and editing a record are al

2条回答
  •  悲&欢浪女
    2020-12-28 15:07

    Use this:

    App.YourNewRoute = Em.Route.extend ({
       controllerName: 'controllerName',
       templateName: 'templateName'
     });
    

    Only use initial name like for homeController user "home" thats it.

    Example:

    App.YourNewRoute =  Em.Route.extend ({
       controllerName: 'home',
       templateName: 'home'
    });
    

    Now you can use template and controller methods of "home".

提交回复
热议问题