-
-
Save tcdevs/7005198 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 hidden or 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