0

I need to get data from $scope.List2 object:

<div ng-app="App">
  <div id="firstlist" ng-controller="Controller">
    <table id="requesttable" class="RequestTable">
      <tr ng-repeat="item2 in List2">
        <td class="selectedItem">{{item2.Title}}</td>
      </tr>
    </table>
    <button id="Reqbutton" onclick="SendRequest()">Send</button>
  </div>
</div>

The problem is that if I put SendRequest function inside controller then it cannot be called (I get "SendRequest() is not defined" message). And if I put the function outside the controller I cannot access List2. What do I miss?

1
  • 1
    Attach SendRequest to your $scope and use ng-click instead of click. But before, follow the whole tutorial ;) Commented Jul 31, 2014 at 12:59

1 Answer 1

1

As @sp00m suggested. You should use ng-click instead of onclick on the button. The html would look like this then:

<button id="Reqbutton" ng-click="sendRequest()">Send</button>

In your controller

app.controller('testController', ['$scope', function {
    $scope.list2 = [];

    $scope.sendRequest = function() {
        var test = $scope.list2;    
        ...
    };

}]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.