title: How to write array which collects ng-click event in AngularJs?
body: <p>I am working with a project, where I need to collect multiple items from user and send it to the server. There is list on my view, where user can click and select the items. My HTML looks like this,</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div ng-repeat="topicList in searchCtrl.topic"&gt;
      &lt;div ng-repeat="topicTerm in topicList"&gt;
         &lt;p&gt;{{topicTerm.number}}&amp;nbsp&amp;nbsp{{topicTerm.name}}&lt;/p&gt;
         &lt;div ng-repeat="subTopic in topicTerm.subTopics"&gt;
            &lt;a href="" ng-click="searchCtrl.select($event)"&gt;{{subTopic.number}}&amp;nbsp&amp;nbsp{{subTopic.name}}&lt;/a&gt;
         &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have used anchor tag, there user can click and at the same time I want the clicked items (which have also unique ID) collected in an Array or variable, which  I need to send (these selected items) to the server via form submission.</p>
  
  <p>This is how my controller looks like,</p>
  
  <p><strong>JavaScript Controller</strong></p>
  
  <pre><code>angular.module('myApp').controller("searchController", function($log, searchService, $scope){
      var self = this;
  
      self.initializeSearch = function(){
  
          self.searchEntry = 
              { 
              "contact":{     
                  "person": "",      
                  "organization": ""
              },  
              "request": {      
                  "input": "",      
                  "language": "en"
              },  
              "topicIds": []
              };
  
      // The POST request must looks like above
  </code></pre>
  
  <p>What I want is that the clicked subTopics IDs collects in an Array "topicIds : []" and I could successfully send the POST request mentioned above. The searchService is a Angular service which helps to get Topics from server and also to POST user input to the server.</p>
  
  <p>This is how my JSON looks like,</p>
  
  <p><strong>JSON API</strong></p>
  
  <pre><code>{  
     "TopicList" :[  
     {
        "id": "798790fa-78c8-4f00-8179-9e70f40adb14",  
        "name": "Topic1",  
        "number": 1.0,  
        "subTopics": [              
            {
               "id": "82c90f2e-deac-4fa4-80f4-d077edacc2dc",  
               "name": "data1.1",  
               "number": 1.1 
            },              
            {
               "id": "0f0c2b89-6dae-4f60-90f8-df49d96b9af9",  
               "name": "data1.2",  
               "number": 1.2
            },    
            {
               "id": "131b68b6-1f45-477f-9b0f-8ac80c5b4f4e",  
               "name": "data1.3",  
               "number": 1.3     
            },           
            {
               "id": "16c8f46d-d20c-48f9-a0c0-e3989763082b",  
               "name": "data1.4",  
               "number": 1.4    
            }   
         ]      
     },
     {
        "id": "9ed3fee0-5347-4f00-9b56-721b61439f88",  
        "name": "Topic2",  
        "number": 2.0,  
        "subTopics": [ 
            {
               "id": "eec13511-1408-4f4b-be6f-8b5a8b6ea28b",  
               "name": "data2.1",  
               "number": 2.1            
            },    
            ...
         ]
     },
     ...
    ]
  }   
  </code></pre>
  
  <p>How to write a function or array which collects the IDs via ng-click event?</p>
  
  <p>Thanks in Advance.  </p>