Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS-在PHP中使用AngularRoute提交表单时不会传递表单参数_Javascript_Php_Angularjs_Routes - Fatal编程技术网

Javascript AngularJS-在PHP中使用AngularRoute提交表单时不会传递表单参数

Javascript AngularJS-在PHP中使用AngularRoute提交表单时不会传递表单参数,javascript,php,angularjs,routes,Javascript,Php,Angularjs,Routes,我在PHP应用程序中使用angularJS路由 我有以下情况: 我有一个名为dashboard.php的主页 我正在ng视图中打开insertEmployee,insertEmployee页面具有包含很少字段的表单。表单标签看起来像 <form action="" method="post"> <!-- all fields --> <input type="submit"> </form> 当点击提交时,整个页面被重新加载,

我在PHP应用程序中使用angularJS路由

我有以下情况:

我有一个名为dashboard.php的主页

我正在ng视图中打开insertEmployee,insertEmployee页面具有包含很少字段的表单。表单标签看起来像

<form action="" method="post"> 
     <!-- all fields -->

<input type="submit">

</form>

当点击提交时,整个页面被重新加载,$_POST['paraName']显示未定义

我不希望整个页面被重新加载。我想用参数在ngView中打开页面

共有8-10个参数,其中一个是员工照片删除
action=”“method=“post”
属性,您不希望浏览器实际发送post请求。相反,您订阅onsubmit事件并自己处理它:

<form ng-submit="save()"> 
    <!-- all fields -->
    <input ng-model="$ctrl.user.username" type="text"> 
    <input type="submit">
</form>
参考资料:

  • 提交
  • $http.post
  • $location

我还想传递参数。有8-10个参数。如果要传递参数,您可以这样做。如何传递?我也想上传图像使用该formEasy!但你为什么现在才告诉我文件上传的事?我建议你更新问题的所有细节。现在的情况如何,我写的东西完美地回答了这个问题。
function save() {
  // post xhr and redirect
  $http.post('/api/user', this.user)
    .then(response => response.data)
    .then(user => $location.path(`/user/details/${user.id}`))

  // or better with service
  users.save(this.user)
    .then(user => $location.path(`/user/details/${user.id}`))    
}