Skip to content

Instantly share code, notes, and snippets.

@danielpsf
Last active December 22, 2015 16:28
Show Gist options
  • Save danielpsf/6499235 to your computer and use it in GitHub Desktop.
Save danielpsf/6499235 to your computer and use it in GitHub Desktop.
A little demonstration about the ng-tree using this component: https://github.com/dump247/angular.tree Take a look here how its work here: http://jsbin.com/EbicERu/3/
<!DOCTYPE html>
<html>
<head>
<meta name="description" />
<meta charset=utf-8 />
<title>Angular Tree</title>
</head>
<body ng-app="myApp" ng-controller="myController">
<ul ng-tree="family">
<li select="selected()">{{item.name}}</li>
</ul>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src="http://cdn.danielpsf.tk/angular.tree.js"></script>
</body>
</html>
var myApp = angular.module('myApp', ['angularTree']);
myApp.controller('myController', function($scope) {
$scope.family = [
{
name: 'Item 1 Name',
children: [
{
name: 'Item 2 Name',
children : [
{
name: 'Item 2.1 Name',
children : [
{
name: 'Item 2.1.1 Name'
},
{
name: 'Item 2.1.2 Name'
}
]
}
]
}, {
name: 'Item 3 Name'
}
]
}
];
$scope.selected = function() {
if(this.$selected){
console.log(this.item.name + ' is selected: ' + this.$selected);
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment