angularJs中ng-readonly和ng-disabled的区别

来源:互联网 发布:工业设备数据采集 编辑:程序博客网 时间:2024/06/08 06:15

**ng-readonly:不能修改,但是可以提交数据
ng-disabled:不能修改,也不可以提交数据**

<!doctype html><html lang="en"><head>    <meta charset="UTF-8">    <script src="angular.min.js"></script></head><body><style>    input[readonly]{background: #f3f3f3;border:solid 1px #aaa;}</style><div ng-app="module" ng-controller="ctrl">    <form action="exam.php" method="post">    <!--readonly数据可以提交-->    <input type="text" name="a" readonly="readonly" value="readonly"><br/>     <!--disabled数据不可以提交-->    <input type="text" name="b" disabled="disabled" value="disabled"><br/>    <input type="submit">    </form>     <!--如果有user.uid,mail不可编辑-->    年龄: <input type="text" ng-model="user.age"><br/>    邮箱: <input type="text" ng-model="user.mail" ng-readonly="user.uid"></div><script>    var m = angular.module('module', []);    m.controller('ctrl', ['$scope', function ($scope) {        $scope.user = {age: 18, uid: 1, mail: '123323232@qq.com'}    }]);</script></body></html>

exam.php

<?phpecho "<pre>";print_r($_POST);
原创粉丝点击