Not sure if this is the best way or not, but from any controller you can just inject the $location service and get the current location/path/url $location.absUrl() Then you can parse this any way you'd like.
https://docs.angularjs.org/api/ng/service/$location /Brian On Thursday, May 14, 2015 at 5:39:57 AM UTC-4, Rahul Saxena wrote: > > Hello I m new in angularjs, I didn't know how to get route parameters like > > > > > > *.when('/edit/:Post_id){//Code here}* > I want to get this to my controller function. > > Here is my controller file: > var myApp = angular.module("blogapp",[]); > > myApp.config(['$routeProvider',function($routeProvider){ > > $routeProvider > .when('/home',{ > templateUrl:'home.html', > controller:'blogcontroller' > }) > .when('/list',{ > templateUrl:'list.html', > controller:'blogcontroller' > > }) > .when('/add',{ > > templateUrl:'add.html', > controller:'addcontroller' > }) > > > > > * .when('/edit/:Blogid',{ // Want to get this id Blogid to edit > controller templateUrl:'edit.html', > controller:'editcontroller' })* > .otherwise({ > redirectTo:'/home' > }); > > }]); > > > myApp.controller('blogcontroller',function ($scope,$http){ > > $http({method: 'GET' , url: 'getallblog.php'}).success(function(data){ > $scope.allblog = data; > }); > > // DELETE blog HERE > $scope.removeRow= function(id){ > > > > $http.post("removeblog.php",{'id' : > id}).success(function(data,status,headers,config){ > window.location='index.html'; > console.log("Deleted Successfully"); > > }); > }; > > // delete blog code ends here > > > }); > > > myApp.controller('addcontroller',function ($scope,$http){ > > > > > > /// New Post Here > $scope.new_post =function(){ > > > > $http.post("addblog.php" ,{'title' : $scope.title ,'description' : > $scope.description }).success(function(data,status,headers,config){ > window.location='index.html'; > console.log("inserted Successfully"); > }); > }; > > > > // New Post ends Here > > }); > > myApp.controller('editcontroller',function ($scope,$http,$routeParams){ > > > *// I Want to get Here the Blogid for view the particular id record. * > }); > > > -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > > appecite if Anyone help.. Thanks > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
