Skip to content

Commit 90fa092

Browse files
committed
Update dxTree.js
1 parent 5151005 commit 90fa092

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/directives/dxTree.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,25 @@
2020
restrict: 'AEC',
2121
require: req,
2222
scope: true,
23-
compile: function(elm) {
24-
var link = {
23+
compile: function(elm, attr) {
24+
var watchExp = attr[name] || (isRoot ? attr.root : attr.node),
25+
template,
26+
link = {
2527
post: function (scope, elm, attr, ctrl) {
2628
scope.$dxLevel = isRoot ? 0 : scope.$dxLevel + 1;
2729
scope.$dxIsRoot = isRoot;
28-
scope.$dxPrior = scope.$dxParent = isRoot
29-
? parse(attr[name] || attr.root)(scope)
30-
: parse(attr[name] || attr.node)(scope);
3130

3231
elm.html(ctrl.template());
3332
compile(elm.contents())(scope);
33+
34+
function updatePrior(value){
35+
scope.$dxPrior = value;
36+
}
37+
scope.$watch(watchExp, updatePrior);
3438
}
3539
};
3640
if(isRoot){
37-
var template = elm.html();
41+
template = elm.html();
3842
elm.html('');
3943
link.pre = function(scope, elm, attr, ctrl) {
4044
ctrl.template(template);
@@ -57,4 +61,4 @@
5761

5862
comp.directive('dxStartWith', $NodeDirective(true, 'dxStartWith', 'dxStartWith'));
5963
comp.directive('dxConnect', $NodeDirective(false, 'dxConnect', '^dxStartWith'));
60-
}());
64+
}());

0 commit comments

Comments
 (0)