I'm new to AgularJs, and I'm working on a single page application. I was stuck on a position where i need to send an dynamic id to next template (i.e /pagename&id= ) and that needs to be control using ng routing as well. Is there a way to handle routing url with this dynamic id value?
This is the code snippets that matters
//Controller function call here passing the dynami id on 'data-value'
<button type="submit" data-value="<dynami id>" ng-click="submit();">
//controller function
var app = angular.module('myApp', []);
var id = <Dynamic id>;
app.controller('galleryController', function($scope, $http, $location) {
$scope.submit = function() {
$location.path('/gallary-single&id='+id);
}
});
//Routing...
app.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl : 'pages/home.html',
controller : 'mainController'
})
.when('/gallary', {
templateUrl : 'pages/gallary.html',
controller : 'galleryController'
})
.when('/gallary-single', {
templateUrl : 'pages/gallary-single.html',
controller : 'gallerySingleController'
});
});