June 2014
Intermediate to advanced
696 pages
38h 52m
English
Next, you need to implement a controller to support the photo portion of the page. Listing 27.16 shows the photoController code. Notice that commentSrv is injected into the controller, along with the $http service.
The controller initializes $scope.photos and $scope.photo, using an $http GET request to the /photos route. The $scope.loadComments() function uses the commentSrv.getComment() function to retrieve the comments for the current photo by passing $scope.photo.commentId. The callback function simply sets the $commentThread value that is used in the view.
The $scope.addReply() method is called when the user clicks Send for a comment reply in the template. Notice that it first generates a newComment object ...
Read now
Unlock full access