ngComponentUtility
ngComponentUtility copied to clipboard
can it support module.component({'myInput': myInput}) ?
register a component like this:
// my-input.component.ts
import { IComponentOptions, IController, INgModelController } from 'angular';
export const myInput: IComponentOptions = {
template: require('./my-input.component.html'),
require: {
ngModelCtrl: '^ngModel'
},
controller: class implements IController {
ngModelCtrl: INgModelController;
get val(): string {
return this.ngModelCtrl.$modelValue;
}
set val(val: string) {
this.ngModelCtrl.$setViewValue(val);
}
}
}
// common.module.ts
import * as angular from 'angular';
import { myInput } from 'components/my-input/my-input.component';
import { myButton } from 'components/my-input/my-button.component';
angular
.module('app.common')
.component({ myInput, myButton})
Hi,
unfortunately it's not supported yet. Almost every single possible use has to be handled separately. I don't have much time to develop this extension recently but I'll be happy to support and accept PRs.
+1
I also register my components in this fashion:
// my-component.ts
export const myComponent: ng.IComponentOptions = {
template:
`some html`,
bindings: {
prop1: '<',
valueText: '<',
}
};
// app.ts
import { gauge } from './my-component';
angular.module('...')
.config([() => {
// ...
}]])
.component('myComponent', myComponent)
.component('x', x)
.component('y', y)
//...
;
Would be awesome if you supported it.