标签:
1.Angular优点
1 <!doctype html> 2 <html lang="en" ng-app="todoList"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>todoList</title> 6 <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/> 7 </head> 8 <body ng-controller="TaskCtrl"> 9 <div class="input-group"> 10 <input class="from-control" type="text" ng-model="task" /> 11 <span class="input-group-btn"> 12 <button class="btn btn-default" ng-click="add()">提交</button> 13 </span> 14 </div> 15 <h4 ng-hide="tasks.length==0">任务列表</h4><!--先生成标签--> 16 <!-- <h4 ng-if="tasks.length>0">任务列表</h4>需要时候才生成标签--> 17 <ul class="list-group"> 18 <li class="list-group-item" ng-repeat="item in tasks">{{item}} 19 <a href="javascript:;" ng-click="tasks.splice($index,1)">删除</a> 20 </li> 21 </ul> 22 <script type="text/javascript" src="js/angular.js"></script> 23 <script type="text/javascript"> 24 var app = angular.module(‘todoList‘,[]); 25 app.controller(‘TaskCtrl‘, function ($scope) { 26 $scope.task = ‘‘; 27 $scope.tasks = []; 28 $scope.add = function(){ 29 $scope.tasks.push($scope.task); 30 }; 31 }); 32 </script> 33 </body> 34 </html>
标签:
原文地址:http://www.cnblogs.com/zshh/p/5439336.html