angular2-decorators

How to pass observable value to @Input() Angular 4

放肆的年华 提交于 2019-12-08 14:35:59
问题 I am new to angular and I have the following situation which is I have a service getAnswers():Observable<AnswerBase<any>[]> and two components that are related to each other. online-quote dynamic-form online-quote component calls the service getAnswers():Observable<AnswerBase<any>[]> in its ngOnInit() method and the result of this, is passed to the component dynamic-form . To illustrate the situation this is the code of my two components: online-quote.component.html: <div> <app-dynamic-form

Angular2 - is it possible to get component class name using selector name

…衆ロ難τιáo~ 提交于 2019-12-07 10:26:50
问题 Is it possible to get component class name or component reference using selector name in Angular 2? @Component({ selector: 'selector-1', template: '<h1>Hello</h1>', }) export class Component1 {} @Component({ selector: 'selector-2', template: '<h1>Hello</h1>', }) export class Component2 {} In component 2 is it possible to get the component1 class name using selector "selector-1"? Example: getComponentName(selectorName) { // return component name } getComponentName('selector-1'); Thanks in

Angular2 - is it possible to get component class name using selector name

ぃ、小莉子 提交于 2019-12-05 17:21:00
Is it possible to get component class name or component reference using selector name in Angular 2? @Component({ selector: 'selector-1', template: '<h1>Hello</h1>', }) export class Component1 {} @Component({ selector: 'selector-2', template: '<h1>Hello</h1>', }) export class Component2 {} In component 2 is it possible to get the component1 class name using selector "selector-1"? Example: getComponentName(selectorName) { // return component name } getComponentName('selector-1'); Thanks in advance It is possible without additional work only if you do not call enableProdMode : var node = document

Accessing `selector` from within an Angular 2 component

可紊 提交于 2019-11-29 13:17:39
问题 I'm trying to figure out how I can access the selector that we pass into the @Component decorator. For example @Component({ selector: 'my-component' }) class MyComponent { constructor() { // I was hoping for something like the following but it doesn't exist this.component.selector // my-component } } Ultimately, I would like to use this to create a directive that automatically adds an attribute data-tag-name="{this.component.selector}" so that I can use Selenium queries to reliably find my

How to retrieve a component's metadata in Angular

一笑奈何 提交于 2019-11-27 21:51:31
问题 An Angular component has decorators: @Component({ ... }) export class MyAngularComponent { @Input() myInputParam: MyType; @Input() myOtherInputParam: MyOtherType; @Output() myOutputParam: MyOtherOutputType; } I've got an Angular library where a lot of code repetitions could be avoided (and bundle size reduced) if I could programmatically retrieve Angular's @Input() decorators inside a given component class (that belongs to the library, though) . But I have doubts on the portability of such an