zoukankan      html  css  js  c++  java
  • 创建双向数据绑定 ng-model

    双向数据绑定会从两个方向同时跟踪变化,允许元素从用户处收集数据以修改程序的状态。双向绑定通过 ng-model 指令来创建

    <!doctype html>
    <html lang="en" ng-app="exampleApp">
    <head>
    <meta charset="UTF-8" />
    <title></title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
    <script type="text/javascript" src="js/angular.js"></script>
    </head>
    <body>
    <div id="todoPanel" class="panel" ng-controller="defaultCtrl">
    <h3 class="panel-header">To Do List</h3>

    <div class="well">
    <div>
    The first item is: {{todos[0].action}}
    </div>
    </div>

    <!--ng-model 双向绑定,仅能应用在那些允许用户输入的标签上-->

    <div class="form-group well">
    <label for="firstItem">Set First Item</label>
    <input name="firstItem" class="form-control" ng-model="todos[0].action" />
    </div>
    </div>
    <script type="text/javascript">
    angular.module("exampleApp",[])
    .controller("defaultCtrl",function($scope){
    $scope.todos=[
    {action:"get groceries",complete:false},
    {action:"call number",complete:true},
    {action:"buy shoes",complete:true},
    {action:"buy flower",complete:false},
    {action:"play",complete:true}
    ]
    })
    </script>
    </body>
    </html>

  • 相关阅读:
    ScrollView 字典
    centos 6.x 安装redis
    Linux 添加epel源
    Linux 关于解压
    Linux 删除文件夹
    Linux sz rz
    让div 实现 input效果
    解决js浮点数计算bug
    键盘绑定事件和焦点处理
    npm的镜像替换成淘宝
  • 原文地址:https://www.cnblogs.com/debra/p/6363166.html
Copyright © 2011-2022 走看看