AngularJS:用于输入模糊变化的观察表单

时间:2016-08-29 09:29:39

标签: javascript angularjs angularjs-directive

我最近搜索了很多次,并没有找到任何好的答案或正确的解决方案。我想创建一个指令来控制我的表单输入更改模糊。它用于编辑工具内的用户设置。

因此,用户正在从名为'generall'的表单中单击输入字段,直到此处不应该发生,如果用户正在编辑(打字)也不应该发生。现在用户点击外部(模糊)字段,指令应该调用类似'updateSettings'的函数,并为它们提供表单名称(generall)和字段中的所有名称+值。

可能看起来像var vars = { formName: 'generall', fields: {ALLFIELDS} }

我已尝试使用该功能:

return {
  require: "form",
  link: function(scope, element, attrs){z
    var cb = $parse(attrs.formOnChange);
    element.on("change", function(){
      cb(scope);
    });
  }
}; 

这是我的代码:https://plnkr.co/edit/KrjtJVCS9kxRckMH3Mv6?p=preview

1 个答案:

答案 0 :(得分:0)

使用

    include ("db_conection.php");

    if (isset ( $_GET ['view'] )) {
        $view_id = $_GET ['view'];

        $query_run = null;

        $query1 = "SELECT * FROM question where testid ='" . $view_id . "'";
        $run = mysqli_query ( $conn, $query1 ); // here run the sql query.
        while ( $row = mysqli_fetch_array ( $run ) )            // while look to fetch the result
                                             // and store in a array $row.
        {

            echo '  

  <tr>
  <td>' . $row ['qid'] . '</td>
  <td>' . $row ['testid'] . '</td>
  <td>' . $row ['questions'] . '</td>
  <td>
  <a href="remove_question.php?del=' . $row ['qid'] . '" class = "btn btn-danger btn-block">Delete</a>

  </td>
  </tr>

        ';

        }

        if (isset ( $_POST ['del'] )) {
            $delete_id = $_POST ['del'];
            $delete_query = "Delete  from question WHERE qid='".$delete_id."'"; // delete
                                                                            // query

            // $run=mysqli_query($conn,$delete_query);
            $run = $conn->query ( $delete_query );
            if ($run) {
                // bootstrap class to open in the same window
                /*
                 * echo "<script>window.open('Admin Delete
                 * member.php','_self')</script>";
                 */

                echo "<script>window.open('remove_question.php','_self')</script>";

                echo '

<div align = "center" style = "margin-top:10px;" class = "alert alert-success">deleted...</div>

';
            } else {

                echo "deletion field";
            }

        }

    }

示例指令

element.on("blur",function(){})