Skip to content

Adapter syntax does not support "controller as" syntax #119

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

Closed
GrzegorzzBB opened this issue Sep 23, 2016 · 6 comments
Closed

Adapter syntax does not support "controller as" syntax #119

GrzegorzzBB opened this issue Sep 23, 2016 · 6 comments

Comments

@GrzegorzzBB
Copy link

GrzegorzzBB commented Sep 23, 2016

var match = expression.match(/^(\S+)(?:\s+on\s+(\w(?:\w|\d)*))?$/);

This is regexp used to find controller's scope by given controller name, but it doesn't support "controller as" syntax:
ng-controller="MainCtrl as mainCtrl"

ui-scroll.js 531:
var controller = candidate.attr('ng-controller');
This will make {controller} variable equal MainCtrl as mainCtrl, which you can't define as adapter expression because regexp will fail.

@dhilt
Copy link
Member

dhilt commented Sep 29, 2016

@GrzegorzzBB I commited one new demo on "controller as" syntax for you, it's available here. I believe it could help you. If not, please let us know...

@GrzegorzzBB
Copy link
Author

GrzegorzzBB commented Oct 13, 2016

@dhilt Thank you for your response. I didn't had much time to take a look on it. This seems to work only if mainCtrl controller is bound to ui-scroll parent scope. In my case ui-scroll is nested:
<div ng-controller="MainController as mainCtrl">
<my-custom-list-wrapper>
<div ng-include="getListTemplate()">
<div ui-scroll="item in remoteCollection" adapter="mainCtrl.adapter"></div>
</div>
</div>
</div>

Scopes log:
image

Desired scope is the yellow one. I can workaround this using some $parent relation, but I like whole idea of on syntax. Just this regexp seems to not work with controller as syntax.

@dhilt
Copy link
Member

dhilt commented Oct 13, 2016

@GrzegorzzBB thanks! now I think I will be able to see the problem, let me try to solve it...

@mfeingold
Copy link
Contributor

@GrzegorzzBB just checked in changes so that you can use the on syntax for controllers defined with as. Please check it out and let us know if it addresses your issue

@dhilt
Copy link
Member

dhilt commented Oct 30, 2016

@GrzegorzzBB the issue with nested scopes and "Controller As" syntax should go away after today's commits. Please try the latest source code https://github.com/angular-ui/ui-scroll/blob/master/src/ui-scroll.js. The template you posted above does not need to be modified. If there's still any problem please let us know, post details or create demo.

@dhilt
Copy link
Member

dhilt commented Nov 18, 2016

@GrzegorzzBB v1.5.2 is released. Please try the latest and reopen the issue if needed.

@dhilt dhilt closed this as completed Nov 18, 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

3 participants