Angular Finder Tree is a directive that generate a selectable tree similar to a file explorer.
AngularJS v1.2+
Chrome | Firefox | Safari | Opera | IE9+ |
---|---|---|---|---|
$ bower install finder-tree --save
<!DOCTYPE HTML>
<html>
<head>
<link href="https://github.com/jperugini/finder-tree/blob/master/finder-tree/dist/finder-tree.min.css" rel="stylesheet" type="text/css" />
</head>
<body ng-app="app">
//.....
<script src="https://github.com/jperugini/finder-tree/raw/master/finder-tree/dist/finder-tree.min.js"></script>
</body>
</html>
angular.module('app', [
'finderTree'
]);
<finder-tree data="data" ng-model="model" search-filter="search"></finder-tree>
The JSON data passed to the directive should be a tree of elements:
{
'name': 'MainDir',
'dirs': [{
'name': 'SubDir1',
'dirs': [{
'name': 'SubSubDir1',
'dirs': [{...}],
'files': [{...}]
}, {
...
}],
'files': [{
'name': File1'
}, {
....
}]
}
}
Each layer of the data structure MUST contain a property dirs and a property files even if this is empty. For example: 'dirs': [{ 'name': 'SubSubDir1', 'dirs': [], 'files': [] }, { ... }],
ng-model should be any variable in your controller. The directive will store the selected file and the path to the file.
{
'name': 'File1',
'any other attribute': '',
'path': ['Array path to file1']
}
You can edit the default Css file finder-tree.css
if you want to make a new theme.
Feel free to contribute by forking, opening issues, pull requests etc.
Released under the terms of MIT License.