Instead of getting a ctrls
array, you get them now by name, just like bindings
use to:
class MyComponentController implements ng.IComponentController {
public modelCtrl: ng.INgModelController;
...
...
// use modelCtrl here
// instead of ctrls[0]
...
...
}
const MyComponent: ng.IComponentOptions = {
template: '...',
bindings: {...},
require: {modelCtrl: 'ngModel'},
controller: MyComponentController
}
angular.module('myModule').component('MyComponent', MyComponent);
Or, if you prefer plain JS:
function MyComponentController() {
...
...
// use this.modelCtrl here
...
...
}
var MyComponent = {
template: '...',
bindings: {...},
require: { modelCtrl: 'ngModel' },
controller: MyComponentController
};
angular.module('myModule').component('MyComponent', MyComponent);