This is My html Page whare i add ng-app="myApp" And ng-controller="DashCtrl"
<form action="" ng-submit="dashForm(dashdata)" method="post">
<input type="hidden" name="uid" ng-model="dashdata.uid"
value="<?php echo $row["id"];?>">
<input type="submit" name="edit" value="Edit">
</form>
And this is angular Code
myApp.controller('DashCtrl', ['$scope', '$http', function($scope, $http) {
$scope.dashForm= function(dashdata)
{
var encodedString = 'action=Userview'+'&id='+dashdata.uid;
alert(encodedString);
$http({
method: 'POST',
url: 'ajaxprocess.php',
data: encodedString,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
})
.success(function(data) {
console.log(data);
if( data.trim() === 'admin') {
window.location.href ='dashbord.php';
}
if( data.trim() === 'user') {
window.location.href ='test.php';
} else {
$scope.errorMsg = data;
// statement
}
})
}
}]);
this send me an error ui is not defined, alert messsege display but is show ui=undefined
Try this:
<form action="" ng-submit="dashForm()" method="post">
<input type="hidden" name="uid" ng-model="dashdata.uid"
ng-init="<?php echo $row["id"];?>">
<input type="submit" name="edit" value="Edit">
</form>
and in controller:
var encodedString = 'action=Userview'+'&id='+$scope.dashdata.uid;
Hope it will help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.