Angularjs的第一个例子

<!DOCTYPE html>
<meta charset='UTF-8'>
<html ng-app='todolist' ng-controller='TaskCtrl'>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
</head>
<body style='padding:10px'>
     <div class="input-group">
         <input ng-model='task' type='text' class="form-control"></input>
         <span class="input-group-btn">
             <button class='btn btn-default' ng-click='add()'>提交</button>
         </span>
     </div>
     <h4 ng-hide='tasks.length==0'>任务列表</h4>
     <ul class="list-group">
         <li ng-repeat="item in tasks track by $index" class="list-group-item">{{item}}
        <a ng-click='tasks.splice($index,1)'>删除</a>
         </li>         
     </ul>
     <script src='./js/angular.min146.js'></script>
    <script type='text/javascript'>
        angular.module('todolist',[])
        .controller('TaskCtrl',function($scope){
            $scope.task='';
            $scope.tasks=[];
            $scope.add=function(){
                $scope.tasks.push($scope.task);
            }
        })
    </script>
</body>
</html>

 

posted @ 2016-06-04 18:04  寅春树  阅读(96)  评论(0编辑  收藏  举报