Angular
This document shows you haw you can create an FamilyTree JS 2 Angular project.
-
Create a new project:
ng new familytree
-
Go to the project root folder:
cd familytree
-
Install FamilyTree JS 2
- Download FamilyTree JS 2.
-
Extract the package and edit the familytree.d.ts file to add the following row at the end of it:
export default FamilyTree2
- Create a folder balkanapp in \src\assets and add your extracted familytree.js and familytree.d.ts files there.
-
Add the familytree.js file in the scripts in your angular.json file.
"src/assets/balkanapp/familytree2.js"
-
In the app.component.html file add or replase the content with this:
<div id="tree"></div>
-
In your app.component.ts add this reference:
import FamilyTree2 from "../assets/balkanapp/familytree2";
constructor() { } ngOnInit() { const tree = document.getElementById('tree'); if (tree) { var familyTree = new FamilyTree2(tree); familyTree.readOnly = false; familyTree.addFamilyMembers([ {id: 1, spouseIds: [2], motherId: 3, fatherId: 4}, {id: 2}, {id: 3}, {id: 4}, ]).draw(1); } }
-
In style.css add this:
html, body, #tree { height: 100%; }
-
Start the project:
ng serve