Search code examples
angularjsjqwidget

using jqWidgets "jqx-instance" with ngController scope-property syntax


How do we use the jqWidgets jqx-instance attribute when used with the ngController scope-property syntax: Controller as myController? see: Angular docs on ngController

for example, this does not work as it should:

<div ng-controller="MainController as main">
    <jqx-button jqx-instance="main.myButton"></jqx-button>
</div>

in the controller, this.myButton should point to the instance, but it is undefined!

Using the other declaration style, i.e., by injecting $scope into the controller, is lame. With more complex applications we need the more specific syntax to promote clarity, isolation, modularity, etc., especially when different parts are coming from multiple developers.


Solution

  • I looked into the source and the ngController scope-property syntax is not supported... but it's easy enough to fix (see jqxangular.js:278). And such a fix falls within the terms of the jqWidgets license... although I can't post any code here.