Skip to content

Commit 55ee7d5

Browse files
Merge pull request #38 from tjjalava/master
Move string-child conversion before uid-assignment
2 parents ade4116 + 0f2e87a commit 55ee7d5

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/abn_tree_directive.coffee

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
module = angular.module 'angularBootstrapNavTree',[]
32

43
module.directive 'abnTree',['$timeout',($timeout)->
@@ -144,23 +143,7 @@ module.directive 'abnTree',['$timeout',($timeout)->
144143
on_treeData_change = ->
145144

146145
#console.log 'tree-data-change!'
147-
148-
# give each Branch a UID ( to keep AngularJS happy )
149-
for_each_branch (b,level)->
150-
if not b.uid
151-
b.uid = ""+Math.random()
152-
console.log 'UIDs are set.'
153-
154-
155-
# set all parents:
156-
for_each_branch (b)->
157-
if angular.isArray b.children
158-
for child in b.children
159-
child.parent_uid = b.uid
160-
161-
162-
scope.tree_rows = []
163-
146+
164147
#
165148
# if "children" is just a list of strings...
166149
# ...change them into objects:
@@ -180,6 +163,23 @@ module.directive 'abnTree',['$timeout',($timeout)->
180163
else
181164
branch.children = []
182165

166+
167+
# give each Branch a UID ( to keep AngularJS happy )
168+
for_each_branch (b,level)->
169+
if not b.uid
170+
b.uid = ""+Math.random()
171+
console.log 'UIDs are set.'
172+
173+
174+
# set all parents:
175+
for_each_branch (b)->
176+
if angular.isArray b.children
177+
for child in b.children
178+
child.parent_uid = b.uid
179+
180+
181+
scope.tree_rows = []
182+
183183

184184
#
185185
# add_branch_to_list: recursively add one branch

0 commit comments

Comments
 (0)