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/#

  • 相关阅读:
    CF 526F Max Mex(倍增求LCA+线段树路径合并)
    CoderForces Round526 (A~E)题解
    牛客OI周赛4-提高组 A K小生成树(kmst)
    Codeforces 1072 C
    Codeforces 1053 C
    牛客国庆集训派对Day3 B Tree
    牛客国庆集训派对Day3 I Metropolis
    牛客国庆集训派对Day3 A Knight
    牛客国庆集训派对Day3 G Stones
    Codeforces 1053 B
  • 原文地址:https://www.cnblogs.com/wang715100018066/p/7356147.html
Copyright © 2011-2022 走看看