Defining the Table AngularJS Controller
With the /word
route handler in place, you can implement the AngularJS controller that accesses the list of words displayed in the table. Listing 29.17 implements tableController
in the AngularJS application Module
object.
The first few lines define the words array, which contains the data for the table as well as the contains
, limit
, skip
, and direction
values used in the $http GET
request to retrieve the set of words. The sortFields
array provides data to select which field to sort on.
The getWords()
function makes an $http GET
request to the /words
route and populates the $scope.words
array that is bound to the table data with the results. Notice that the limit
, skip
, sort
, direction
, and contains
fields ...
Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.