Advertisement
asimryu

angualrJS with filter

Apr 11th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.08 KB | None | 0 0
  1. <section ng-app="myapp" ng-controller="mynews">
  2.     <h2>뉴스 리스트</h2>
  3.     <hr>
  4.     <p class="text-right">
  5.         <a href="write.php" class="btn btn-success">
  6.             <i class="fas fa-pencil-alt"></i>
  7.             글쓰기
  8.         </a>
  9.     </p>
  10.     <div>
  11.         <form onsubmit="return false;">
  12.             <div class="form-group">
  13.                 <input type="text" class="form-control" placeholder="검색어" ng-model="search">
  14.             </div>
  15.         </form>
  16.     </div>
  17.     <table class="table">
  18.             <tr>
  19.                 <th class="text-center">번호</th>
  20.                 <th class="text-center">제목</th>
  21.                 <th class="text-center">글쓴이</th>
  22.                 <th class="text-center">날짜</th>
  23.                 <th class="text-center">조회</th>
  24.             </tr>
  25.             <tr ng-repeat="news in newslist | filter:search">
  26.                 <td>{{ news.id }}</td>
  27.                 <td>{{ news.title }}</td>
  28.                 <td>{{ news.writer }}</td>
  29.                 <td>{{ news.wdate }}</td>
  30.                 <td>{{ news.hit }}</td>
  31.             </tr>
  32.     </table>
  33. </section>
  34.  
  35. <script>
  36.     var app = angular.module("myapp", []);
  37.     app.controller("mynews", function($scope, $http){
  38.         $http.get("json.php").then(function(news){
  39.             $scope.newslist = news.data;
  40.         });
  41.     });
  42. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement