Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I recompile the layout-dashboard directive ? #158

Closed
vladradulescu1 opened this issue Jan 6, 2016 · 8 comments
Closed

How do I recompile the layout-dashboard directive ? #158

vladradulescu1 opened this issue Jan 6, 2016 · 8 comments

Comments

@vladradulescu1
Copy link

StackOverflow thread: http://stackoverflow.com/questions/34631966/how-to-reload-recompile-refresh-directive-in-angularjs

@awashbrook
Copy link
Contributor

you may find #136 helps your case, although I personally tried out the hack suggested by @andyperlitch and couldn't get it to work!

@vladradulescu1
Copy link
Author

yes, I tried that myself and doesn`t work...

@vladradulescu1
Copy link
Author

We need a way to pass controller scope variables to the directive variables, something like this: http://stackoverflow.com/questions/13318726/easiest-way-to-pass-an-angularjs-scope-variable-from-directive-to-controller >> http://jsfiddle.net/maxisam/QrCXh/

@robertmazzo
Copy link

I've struggled with this for a while regarding the use of the Kendo UI library, and found a hack to force a widget recompile. My original post was #142 .
It started when I discovered the scope.compileTemplate() function call in the widget directive code.

In my case, I searched for the Kendo grid class .k-grid, and found this method on the angular scope object: $angular_scope.compileTemplate();

So in my refresh code, I first look for any Kendo grid in the DOM (another hack):

       var grids = $(angular.element(document.getElementById('dash'))).find('.k-grid');

I then use _.each() to iterate the DOM elements:

      _.each(grids, function (elem) {
             var grid = $(elem).parent().find('.k-grid').data('kendoGrid');  
             // add'l code omitted...
             if (grid) {                    
                 grid.$angular_scope.compileTemplate();          // *** COMPILE TEMPLATE ***
              }
        });

It's not very elegant, but it does recompile my HTML code when I'm dynamically swapping out the templateURL property of the widgets definition.

good luck,
Bob

@vladradulescu1
Copy link
Author

That is interesting, thanks a lot, I also found some sort of solution to my problem. In the first $scope.layoutOptions.widgetDefinitions = define_all_widget_you_want; and then after changes you can redefine $scope.layoutOptions.widgetDefinitions = less_widget_list; I will have same effect (The map has all the widgets but we are displaying less widgets :D ). So in this way I don`t need to swapp the templateUrl or recompile de directive.

@robertmazzo
Copy link

My scenario does not use the layout-dashboard, but I did find the recompile hack useful.
Are you using the WidgetDataModel to configure your widget data ?

@vladradulescu1
Copy link
Author

No, I`m not using any WidgetDataModel yet !!

@wvary
Copy link
Contributor

wvary commented Nov 3, 2016

@pitong accepted the answer on stackoverflow.
Assuming this issue has been resolved.

@wvary wvary closed this as completed Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants