Demo plunker
Project demo on github
** Các thư viện yêu cầu**
<link rel="stylesheet" href="bootstrap.min.css">
<link> rel="stylesheet" href="fontawesome.css">
<script src="underscore.js"></script>
<script src="jquery.js"></script>
<script src="jquery.svg.min.js"></script>
<script src="brat.js"></script>
<script src="angular.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="ui-bootstrap-tpls.min.js"></script>
Thêm javascript và css vào index.html
Chú ý: Thuộc tính component bắt buộc phải có trong thẻ script
<link rel="stylesheet" href="text-annotation.css">
<script src="brat.js">
<script component="text-annotation-script" src="text-annotation.js">
<script src="update-annotation-modal.js">
<script src="new-annotation-modal.js">
Khai báo directive
<text-annotation config="config" doc="doc" editable="true" multilabel="false" confirm="true"><text-annotation>
- Khai báo các file text-annotation.js, update-annotation-modal.js, new-annotation-modal.js
- Tham số: truyền giá trị cho các tham số,
configvàdoctruyền từ controller với $scope, hai tham số còn lạieditablevàmultilabelnhận hai giá trị true và false.
Các tham số trong directive
component(bắt buộc) - có giá trị text-annotation-script là thuộc tính của thẻ script khai báo directive, nhằm xác định đường dẫn tới thư mục chứa code html của các modal annotation.config(bắt buộc) - cấu hình nhãn của textdoc(bắt buộc) - chứa text và các entities cúa các thành phần trong texteditable(mặc định: false) - thay đổi nhãn cho text
true: có thể mở modal update và thêm mới entity cho token
false: không thể mở modal nàomultilabel(mặc định: false) - gán nhiều nhãn cho một token.
true: mở modal thêm mới, lọc bỏ những entity đã tồn tại trong token được chọn trong danh sách entity. Cần đặt giá trị choeditablelà true thì tham sốmultilabelmới có thể nhận sự kiện.
false: không cho mở modal thêm mớiconfirm(mạc định: true) - hiển thị alert xác nhận thao tác
- Mở modal cập nhật hoặc xóa nhãn bằng cách click vào tên nhãn bên trên token.
- Mở modal thêm mới nhãn bằng cách click đúp hoặc bôi đen một đoạn trong text.