How to get value from ng-click and send to queue for query ?
// html
& lt; Div ng-controller = "recipient controller" & gt; & Lt; Div ng-repeat = "recipients in recipients | orderbase: '- created" ng-click = "select (recipient.id)" & gt; & lt; p class = "recipient name" & gt; {{recipient. Name}} // xxController.js
$ scope.select = function () {comment.get () .success (function (data) {$ scope .comments = data; $ scope.loading = false;});}
// xxService.js
get: function () {var Comment = $ http.get ('api / comments'); Return comment;},
// xxController.php [laravel]
public functions Action Index () {$ comments = DB :: table ('c') - & gt; join ('u', 'seed', '=', 'uid') - Select gt; 'U.ID', 'U.Name', 'C Commands',' c. ('U.id', '=', at: :: user () -> ID) -> or where 'U.id', '=', ** 39 = & gt; This part can be from ng-click value **) - & gt; orderbird ('c.created_at', 'asc') - & gt; Received (); Return Feedback: Jason ($ Comments); }
You have passed recipient.id
The parameter is in your ng-click function but you have not retrieved the parameter in your JS function
You need to retrieve the parameter
Select $ scope = function (** id **) {var selectedId = id; // You can check here Comment.get () .success (function (data) {$ scope.comments = data; $ scope.loading = false;}); }
No comments:
Post a Comment