import { Injectable } from '@angular/core'; import { TreeviewItem } from '../../lib'; @Injectable({ providedIn: 'root' }) export class CountryService { getCountries(): TreeviewItem[] { const childrenCategory = new TreeviewItem({ text: 'Rest of world', value: 1, collapsed: true, children: [],checked:false,level:1 }); const itCategory = new TreeviewItem({ text: 'Asia', value: 9,checked:false, collapsed: true,level:1, children: [ { text: 'Afghanistan', value: 91, itemImgurl:'https://www.countryflags.io/AF/flat/64.png',level:2, collapsed: true, stateCount: 3, children: [ // { text: 'Region 01', value: 921 ,checked:false}, // { text: 'Region 02', value: 922,checked:false }, // { text: 'Region 03', value: 923,checked:false } ] }, { text: 'Azerbaijan', value: 92,itemImgurl:'https://www.countryflags.io/AL/flat/64.png',level:2, collapsed: true, stateCount: 5, children: [ // { text: 'Region 01', value: 924 }, // { text: 'Region 02', value: 925 }, // { text: 'Region 03', value: 926 }, // { text: 'Region 04', value: 927 ,checked:false}, // { text: 'Region 05', value: 928 }, ] }, ] }); return [childrenCategory, itCategory]; //return [itCategory]; } getProducts(): TreeviewItem[] { const fruitCategory = new TreeviewItem({ text: 'Fruit', value: 1, children: [ { text: 'Apple', value: 11 }, { text: 'Mango', value: 12 } ] }); const vegetableCategory = new TreeviewItem({ text: 'Vegetable', value: 2, children: [ { text: 'Salad', value: 21 }, { text: 'Potato', value: 22 } ] }); vegetableCategory.children.push(new TreeviewItem({ text: 'Mushroom', value: 23, checked: false })); vegetableCategory.correctChecked(); // need this to make 'Vegetable' node to change checked value from true to false return [fruitCategory, vegetableCategory]; } }