how to pass URL parameter to php variable using angularjs routing?
This is routing_script.js :
var scotchApp = angular.module('HRModuleApp', ['ngRoute']);
scotchApp.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl : 'pages/home.html',
controller : 'mainController'
})
// route for the home page
.when('/home', {
templateUrl : 'pages/home.html',
controller : 'mainController'
})
// route for the contact page
.when('/public_profile:user_id', {
templateUrl : 'pages/public_profile.php',
controller : 'contactController'
})
// route for the contact page
.when('/add_user', {
templateUrl : 'pages/add_user.html',
controller : 'contactController'
});
});
what else should I add to this? how to forward id_user parameter from url to a php variable... so php can execute some sql...
I also read about how angular isnt for something like this... but I need it... and I need it urgently...
thank you!!!
here is the variable $term that needs that url parameter in php file:
<?php
$term = mysql_real_escape_string($_REQUEST['user_id']);
ok, if got your question right you want 'pages/public_profile.php' to read a GET parameter passed by angular so it can be executed before the view is rendered, maybe something like this do the trick:
by changing your 'templateUrl' from a string to a function that dinamicly add the parameter to the url as a get param
this is the javascript that triggers onclick event... a click on a row in datatable... the link I get looks fine, but php script doesnt get that url
In your
contactController
NOTE: You should move all $https calls to a service.