ng-table
ng-table copied to clipboard
Can't access scope inside header template inside component
working demo with controller-as syntax: http://ng-table.com/#/formatting/demo-header-cell-full
my demo with angular component http://plnkr.co/edit/IOJZfWFlJEWo93PWX4Xl?p=preview
Seems like custom template headerCheckbox.html
can't get access to $ctrl variable
I hope author still works on this plugin. It's really great and it's my first problem with it.
Hello @maxkorz, Did you finally made it work ? I'm facing the exact same problem right now :/ Regards
@renaudaste hi. Sorry, but no luck there. I gave up on this idea.
Thank you for your quick answer, I also couldn't find any solution. But will be back on this thread when I make it work.. Well, hopefully :)
@renaudaste I also ran to this problem and solved it in the ugly way.
my.html
<script type="text/ng-template" id="headerCheckbox.html">
<input type="checkbox" ng-model="bindings.ctrl.checked" class="select-all" value="" />
</script>
<div ng-bind="$ctrl.checked"></div>
...
myComponent.js
function myController($scope) {
$scope.bindings = { ctrl: this };
}
angular.module("my-project").component("my", {
templateUrl: "my.html",
controller: myController,
});
What I have done is binding the component's controller to its scope and call it inside child's scope since child's inherit from parent's. I think the reason we cannot use $ctrl in there is because it is reserved for its own scope (child's scope).
A nicer solution would be nice though.
https://github.com/esvit/ng-table/issues/917 worked "fine" for me.
I have met the same problem, any elegant solution?