kashif Riaz
asked on
sending parameters with url in angularjs code when using ng-route
I am creating a shopping list application. without going to deep , here I will try to make my code as short as possible . I have a table in my database named "listsnames". in this table, there are just names of lists created by me (or other users).
these lists are shown on page as below
But problem is that how i will send an id or other parameter with url of that list to targeted page where the targeted page will show data according to the parameters sent with url.e.g. if a list has id "101" then it will be sent to the targeted page and targeted page will fetch data from database where id = "101".
If this problem is solved then my applications is almost complete.Please help me. I have tried my best searching on google but i could not understand the $routeparams service of AngularJs. actually I know $routParams service a bit , but not know where to put the actual value of a parameter which is coming from database
these lists are shown on page as below
<div ng-app = "myapp" ng-controller = "myCtrl">
<ul ng-repeat="x in list">
<li>{{x.listName}}</li>
</ul>
</div>
Angular Code:
var app = angular.module("myapp",[]);
app.controller("myCtrl",function($scope,$http) {
$http.get(
"serversidepage.php"
{'data':'useremail'}
).then(function(response) {
$scope.lists = response.data
})
});
Now all lists names are shown. and it is time that when i click on any list name , the link should be redirect to a page where all items of this list are there Or where new items will be inserted to that list.But problem is that how i will send an id or other parameter with url of that list to targeted page where the targeted page will show data according to the parameters sent with url.e.g. if a list has id "101" then it will be sent to the targeted page and targeted page will fetch data from database where id = "101".
If this problem is solved then my applications is almost complete.Please help me. I have tried my best searching on google but i could not understand the $routeparams service of AngularJs. actually I know $routParams service a bit , but not know where to put the actual value of a parameter which is coming from database
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window
But I will recommend to use ui-router in angular as it is vast and has multilevel routing.