时间:2021-12-03 09:27:24 | 栏目:AngularJS | 点击:次
如下所示:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <script src="angular.min.js"></script> <script src="jquery.min.js"></script> </head> <body> <div ng-app="module" ng-controller="ctrl"> <form method="post" action="ng.php"> 标题: <input type="text" ng-model="field.title"><br/> 点击数: <input type="text" ng-model="field.click"><br/> 内容: <input type="text" ng-model="field.content"><br/> <!--将提交的数据获取放到textarea里面--> <textarea name="data"></textarea> <input type="submit"> </form> </div> <script> var m = angular.module('module', []); m.controller('ctrl', ['$scope', function ($scope) { $scope.field = {title: '泠泠', click: 100,content:'泠泠在路上'}; $('form').submit(function () { $("[name='data']").val(angular.toJson($scope.field)); }); }]); </script> </body> </html>
ng.php
<?php //print_r($_POST); $data = json_decode($_POST['data'],true); var_dump($data);