1
AngularJS에 처음 왔으므로이 작은 것으로 만졌습니다. 사용자 응용 프로그램입니다.AngularJS : jsonplaceholder.typicode.com을 데이터 소스로 사용하면 작동하지 않습니다.
var root = 'https://jsonplaceholder.typicode.com';
// Create an Angular module named "usersApp"
var app = angular.module("usersApp", []);
// Create controller for the "usersApp" module
app.controller("usersCtrl", ["$scope", function($scope) {
$scope.users = root + "/users";
}]);
.search-box {
margin: 5px;
}
.table-container .panel-body {
padding: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container" data-ng-app="usersApp">
<div class="panel panel-default table-container">
<div class="panel-heading">Users</div>
<div class="panel-body" data-ng-controller="usersCtrl">
<div class="row">
<div class="col-sm-12">
<div class="form-group search-box">
<input type="text" class="form-control" id="search" placeholder="Search User" data-ng-model="search">
</div>
</div>
<div class="col-sm-12">
<table class="table table-striped table-bordered" id="dataTable">
<thead>
<tr>
<th>Full name</th>
<th>Email</th>
<th>City</th>
<th>Street</th>
<th>Suite</th>
<th>Zipcode</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="user in users|filter:search">
<td>{{user.name}}</td>
<td><a href="mailto:{{user.email}}">{{user.email}}</a></td>
<td>{{user.address.city}}</td>
<td>{{user.address.street}}</td>
<td>{{user.address.suite}}</td>
<td>{{user.address.zipcode}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
하지만 작동하지 않습니다. 웬일인지 이해할 수 없습니다. 내가 도대체 뭘 잘못하고있는 겁니까? 고맙습니다!
업데이트 : 작동 바이올 HERE.
과 같이해야한다
코드 즉 단지 문자열입니다. 하지만 고마워! –
사소한 버그를 수정했습니다. 이제는 잘 작동합니다. – UchihaItachi
저는 Angular를 배우기 때문에, (실습) 도움을 주시면 감사하겠습니다. 코드를 명시 적으로 설명하도록 주석을 달 수 있습니까? 고맙습니다! –