question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't access scope inside header template inside component

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
mixthcommented, Jun 14, 2017

@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.

0reactions
huizhoujavacommented, Jan 17, 2019

I have met the same problem, any elegant solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No access to scope variables directly inside ng-template
So I recently moved some repeated markup into ng-template blocks, and I noticed that inside the blocks, I do not get direct access...
Read more >
Google C++ Style Guide
Do not use Namespace aliases at namespace scope in header files except in explicitly marked internal-only namespaces, because anything imported into a namespace ......
Read more >
Slots - Vue.js
Everything in the parent template is compiled in parent scope; ... useful for slot content to have access to data only available in...
Read more >
Angular ng-content and Content Projection: A Complete Guide ...
Component Design Problem 3 - Capturing plain browser events of elements inside a template; Component Design Problem 4 - Custom third party input ......
Read more >
Template Designer Documentation - Jinja
To comment-out part of a line in a template, use the comment syntax which is by ... However, per default blocks may not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found