-
Notifications
You must be signed in to change notification settings - Fork 107
properties injection issue with controllerAs #121
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
Comments
any chance you can give us a repro? On plunker or something? |
@bhagn could you try the latest source code (https://github.com/angular-ui/ui-scroll/blob/master/src/ui-scroll.js)? there are some modifications around adapter assignment... If you still facing the issue and don't want to create a demo, please put your full template code in a comment. |
I'm really sorry. I probably missed the mails asking me for a demo. I'm pasting the template code here - will create a demo soon and provide a link.
I'll get back with a jsfiddle demo. |
@bhagn I've just thought that this is a good idea to have such public demo, when the ui-scroll directive is encapsulated within some custom directive with it's own controller. So please follow it (especially the source code), I believe this could help. And again, you should try the latest ui-scroll code wich has not released yet and wich will be a part of ui-scroll 1.5.2 release. |
@dhilt I tried with the master branch. I'm still seeing the same issue - adapter injected into |
Your demo works fine. Here's my demo (still not working :) ) - https://github.com/bhagn/ui-scroll/tree/master/demo/insideComponent Let me know if I need to create a PR for the example. |
@bhagn You have no ui-scroll-viewport in your demo. According to the documentation (the part of assignable expressions):
That are the reasons why the Adapter is being bound to the $scope.$parent.$ctrl (and not to $scope.$parent as you put in a code comment):
Unfortunately the second point is still the problem. Both of cases (Component and Directive) have no pure "Controller As" declaration, I mean the markup. So the scroller has no chance to catch correct scope by DOM traversing... But why the case when we have ui-scroll-viewport does not face this issue? It is so because of $parse("ctrl.adapter").assign executes on the viewport scope wich is under the component/directive's controller scope wich is already existed in the scopes hierarchy with a container object named "ctrl" due to internal angular stuff... And of course this does not work when we have no viewport and trying to $parse "ctrl.adapter" from the $root. So in your demo you should set the viewport directive in the template or provide an access to the adapter right via root-scope. |
@dhilt Thanks for the clarification - I missed that part in the documentation. |
@bhagn I've made a fix for no ui-scroll-viewport case too. Please try ui-scroll v1.5.2. |
@dhilt Having Unfortunately, when debug info is disabled (https://docs.angularjs.org/guide/production), the DOM elements' |
I"m using the ui-scroll in its simplest form -
The problem I'm facing here is the
adapter
instance is not getting injected into the right scope/controller.listCtrl.adapter
remainsundefined
.adapter
attribute toadapter on listCtrl
. It complains saying -Failed to locate target controller 'listCtrl' to inject 'adapter'
.adapter="adapter". This injected the adapter instance into
$scope.$parent` (this is probably as expected).Looking at the code in ui-scoll.js (lines 517 - 524) -
Without specifying
ng-controller
explicitly it looks like the injection doesn't work as expected.The text was updated successfully, but these errors were encountered: