angularjs - Reload directive on click of $http.data -



angularjs - Reload directive on click of $http.data -

basically, i'm trying create remote file browser. when user clicks folder, directive should reload new parameter (the path).

please see code below.

nwkapp.directive('wip', function ($parse, $http, $rootscope, $compile) { var wipapi = 'example.com'; if($rootscope.path === undefined) { $rootscope.path = new array(); wipapi += "?path="+$rootscope.path.join('/'); } homecoming { restrict: 'e',//this makes relevant element. other values attr, or m comment replace: true, templateurl: wipapi, scope : { data: '='//binds whatever in data, reference var, obj or array. }, link: function (scope, element, attrs) { scope.wipbrowse = function(subpath) { $rootscope.path.push(subpath); element.parent().html('<wip></wip>'); }//end wipbrowse }//end link folder }//end homecoming });

basically, template html contains multiple ng-clicks trigger scope.wipbrowse once. replace parent html (in hope i'll trigger directive again), nil happens.

is there easy way trigger directive run again?

i'm not sure if help click events not firing because html replaced not compiled. made modified version of directive:

app.directive('wip', function($compile, $rootscope) { homecoming { restrict: 'e', //this makes relevant element. other values attr, or m comment replace: true, templateurl: 'test.html', scope: { data: '=' //binds whatever in data, reference var, obj or array. }, link: function(scope, element, attrs) { scope.wipbrowse = function(subpath) { alert('alert'); $rootscope.path.push(subpath); element.replacewith($compile('<wip></wip>')(scope)[0]); } //end wipbrowse } //end link folder } //end homecoming });

http://plnkr.co/edit/oyn51ddjzfmhtm4dwj3k?p=preview

angularjs

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -