'What does this app.directive snippet do in Angular?
I have the following snippet of code
app.directive('widthSetter',function($timeout){
return {
restrict: 'A',
link: function (scope, element, attr){
$timeout(function(){
console.log(element);
var el = attr.widthSetter+'_top'
element.css({'min-width': document.getElementById(el).clientWidth+'px'})
scope.$apply();
});
}
}
});
I am fresh to Angular and am picking up some legacy code. I'm having an issue with this code which can be seen here Angular App Not Working When Moving to Python Flask but this question is more along the lines of understanding what this code does so I can therefore hopefully debug the issue.
The app renders a page with dynamically created table depending on what is chosen from a dropdown. Using a combination of console.log()
I can see it seems to be performing an action on each element that has an id ending in _top
In the question I asked above, if let's say the table has 10 columns. The console.log
gets printed 20 times i.e. 2 lots of 10. However for the Python Flask version I get 1 lot of 10 and then 10 errors.
So yeah, could someone please clarify what this code does (hopefully the context I've provided helps!) and/or explain why I may be getting an error in Python Flask and not Classic ASP despite the JS files being exactly the same
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|