zoukankan      html  css  js  c++  java
  • todolist

    总结:

    1,ng-if,判断数组的个数大于0,则为true,就显示;,

    2,允许添加重复的数据 track by $index;

    <!DOCTYPE html>
    <html ng-app="myApp">
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css">
      <script type="text/javascript" src="https://cdn.bootcss.com/angular.js/1.6.5/angular.js"></script>
      <script type="text/javascript" src="https://cdn.bootcss.com/angular-ui-router/1.0.3/angular-ui-router.js"></script>
      <style>
        .del{
          float:right;
        }
      </style>
    </head>
    <body ng-controller="formCtr">
    <form action="" class="form-inline" role="form">
      <div class="form-group">
        <input ng-model="text" class="form-control" type="text">
      </div>
      <p>{{text}}</p>
      <button type="button" class="btn btn-primary" ng-click="add()">提交</button>
    </form>
    <h1 ng-if="teams.length>0">增加的条目</h1>
    <ul>
      <!--允许添加重复的数据track by $index-->
      <li ng-repeat="team in teams track by $index">{{team}}
        <a class="del" href="#" ng-click="teams.splice($index,1)">删除</a>
      </li>
    </ul>
    </body>
    </html>
    <script type="text/javascript">
    angular.module('myApp',[])
        .controller('formCtr',['$scope',function ($scope) {
            $scope.text = "";
            $scope.teams = [];
            $scope.add = function () {
                $scope.teams.push($scope.text);
                $scope.text = "";
            }
        }])
    </script>

    预览:https://besswang.github.io/todolist/#

  • 相关阅读:
    Codeforces Round #384 (Div. 2)
    Codeforces Round #383 (Div. 2)
    bzoj-4514(网络流)
    bzoj-4518 4518: [Sdoi2016]征途(斜率优化dp)
    bzoj-1096 1096: [ZJOI2007]仓库建设(斜率优化dp)
    hdu-5988 Coding Contest(费用流)
    hdu-5992 Finding Hotels(kd-tree)
    用链表实现杭电1276士兵队列训练问题
    循环链表
    图书管理系统
  • 原文地址:https://www.cnblogs.com/wang715100018066/p/7356147.html
Copyright © 2011-2022 走看看