Skip to content

properties injection issue with controllerAs #121

Closed
@bhagn

Description

@bhagn

I"m using the ui-scroll in its simplest form -

<div ui-scroll="item in datasource" adapter="listCtrl.adapter">
  <div ng-bind="::item.name"></div>
</div>

The problem I'm facing here is the adapter instance is not getting injected into the right scope/controller. listCtrl.adapter remains undefined.

  • I tried changing the adapter attribute to adapter on listCtrl. It complains saying - Failed to locate target controller 'listCtrl' to inject 'adapter'.
  • I set 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) -

while (candidate.length) {
  let controller = candidate.attr('ng-controller');
  if (controller === controllerName) {
    scope = candidate.scope();
    break;
  }
  candidate = candidate.parent();
}

Without specifying ng-controller explicitly it looks like the injection doesn't work as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions