ngComponentUtility icon indicating copy to clipboard operation
ngComponentUtility copied to clipboard

can it support module.component({'myInput': myInput}) ?

Open onlymisaky opened this issue 6 years ago • 2 comments

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})

onlymisaky avatar Dec 14 '18 06:12 onlymisaky

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.

ipatalas avatar Dec 15 '18 19:12 ipatalas

+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.

johnknoop avatar Jan 21 '20 19:01 johnknoop