Last active
December 22, 2015 16:28
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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