We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Redirect to other View on Click

I have a Users table in the user view, which contains a column for sales with add button. by clicking on add button it should redirect to the sales view and pre-filled up the input fields with user details. the table is as below :

 <table class="row-border hover" datatable="ng">
    <thead>
          <tr>
             <th class="thbg">Sr.</th>
             <th class="thbg wd-wide">Name</th>
             <th class="thbg">Type</th>
             <th class="thbg">Contact</th>
             <th class="thbg">Sales</th>
             <th class="thbg">Action</th>
         </tr>
     </thead>
     <tbody>
         <tr ng-repeat="list in table.customer_list">
             <td>{{$index + 1}}</td>
             <td>{{ list.prefix + ' ' + list.firstname + ' ' + list.lastname}}</td>
             <td>{{ list.type}}</td>
             <td>{{ list.contact}}</td>
             <td>{{ list.sales}} <button class="btn btn-sm btn-info pull-right tbar"><i class="fa fa-plus-square fa-lg"></i></button>
             </td>
             <td>
                <div demo> 
                    <button class="btn btn-sm btn-warning tbar pull-right" ng-click="table.scroll();table.showForm=true; table.edit(list.id)">
                        <i class="fa fa-pencil-square fa-lg"></i>
                   </button>
               </div>
            </td>
         </tr>
     </tbody>
 </table>

I am using Angularjs at client side. How do I switch controller with parameters.

I googled for the problem and found that $broadcast and $emit is used to event propgation in angularjs. but still can't get the solution because $broadcast sends event to child controllers and $emit sends event to parent controller. whereas I have sibbling controller, not in a scope tree.

edited Sep '17

If you want a simple redirect to another page use a <a> link or a form to post some data. If you want to add it in the current page, you just need to call an ajax plain text result request on post or get with params depend on your needs then in the action of the route that you use, disable the layout and send the params to the view to set the table with all good data.
You'll get the result of the html corresponding of your table in plain text then can be added anywhere in the body.

$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);