<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>AngularJS example2</title>
<style>
body{
background-color:#ddf;
font:16px bold Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
input{
padding:10px;
}
#list-container{
background-color:white;
color:#448;
border-radius:25px;
border:1px solid black;
padding:25px;
}
</style>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app>
<p>Search Departments:<input type="text" placeholder="Enter search string" ng-model="searchString"></p>
<div ng-init="departments = [
{name:'Sales', contact:'Marsha Brown'},
{name:'Support', contact:'Dave Price'},
{name:'Production', contact:'Grant Wales'},
{name:'Service', contact:'Sherry Dell'},
{name:'Administration', contact:'Sally Bennett'},
{name:'Accounting', contact:'Kim Sutherland'},
{name:'Shipping', contact:'Sandy Connell'}]">
</div>
<div id="list-container">
<ul>
<li ng-repeat="dept in departments | filter: searchString">{{dept.name + "("+ dept.contact +")"}}</li>
</ul>
</div>
</body>
</html>
相关分类