0

I have HTML structure like this

  <aside class="side" align="left">
     <table onclick="reply_click(event)" ng-controller="TableCtrl" >
           <tr ng-repeat = "table in tables">
             <td><button id = "{{table}}" width = "70">{{table}}</button></td>
           </tr>
     </table>
  </aside>
  <article class="tabs">


      <section id="erd">
        <h2><a href="#erd">ERD</a></h2>
        <p>This content appears on tab ERD.</p>
      </section>

      <section id="col">
        <h2><a href="#col">Columns</a></h2>
    <h2><a href="#col">Columns</a></h2>
    <div id="list" ng-controller="ColCtrl">
      <table>
        <tr>
            <th>Column Name</th>
        </tr>
        <tr ng-repeat="column in columns">
            <td>{{column.name}}</td>
        </tr>
      </table>
    </div> 
      </section>

      <section id="home">
        <h2><a href="#home">Home</a></h2>
        <p>This content appears on tab Home. lfkdgl;k  lkfd;lkg ';lkfg ;lkg 'df;lk ;lk ';lk ';fdlkg ';fdlkg';dflk;ldfkg';lkdlfkdfkglkdf lkjhlsdjhfljdfhlkjdh jh jhkjdhfkjsdhf skjdhf lk h dsfjlkjsdlkfj;dslkfj  dskfj;kj sdfkj fkdj;lfkjsd;lkfj   sdkfj ;slkj sdfj;lskjf   skdj flksjdf ; sdfkj ;sdlkfj dskfj sdkjfhueuu suehu heu he u heu heh ueh ufhu fhe uueh ush uhsudh ue huhuhufheuheu u heiu h euh eh ue </p>
      </section>

  </article>

I used the suggestions from this SO answer to call a controller AngularJS. How to call controller function from outside of controller component

The controller I and calling is

angular.element(document.getElementById("list")).scope().loadColumns();

It fires correctly. The problems I am calling it from a button in TableCtrl component. After loadColumns() is fired it went to the TableCtrl component to loop which is the wrong place. How can I tell it to go to the correct place ColCtrl area to loop and populate data?

Thanks,

Community
  • 1
  • 1
Shawn
  • 5,130
  • 13
  • 66
  • 109
  • Using the `onclick` event is a bit of an antipattern for Angular. If you need that much communication between objects, I would be inclined to use one controller on a higher-up element. Angular wasn't designed to communicate between controllers in that way. – AJ Richardson Mar 15 '16 at 03:48
  • AJ Richardson, thanks for the comment. It's good to know that. – Shawn Mar 15 '16 at 21:29

0 Answers0