angular-decorator

Difference between @Self and @Host Angular 2+ Dependency Injection Decorators

依然范特西╮ 提交于 2019-12-03 03:31:14
Kindly explain the difference between @Self and @Host . The angular API documentation gives some idea. But it's not clear to me. The example provided for Self uses ReflectiveInjector to exemplify usage. However, one would rarely, if ever, use ReflectiveInjector in actual app code (probably more in testing).. Can you give an example of where you would use @Self instead of @Host outside of such test scenarios?? tl;dr It looks like when @Self is used, Angular will only look for a value that is bound on the component injector for the element that this Directive/Component exists on. It looks like

Can't get to @ViewChildren in parent component

不羁的心 提交于 2019-12-01 00:20:41
I am trying to get control over the children instances of a component and can't go past an error. I am trying to follow along the answers from this issue . The parent component Sequence contains children components of SequenceStep . The parent contains the following declaration: @ViewChildren(SequenceStep) steps: QueryList<SequenceStep>; then I am trying to do something about the children: ngAfterViewInit() { this.steps.changes.subscribe(steps => { console.log(steps); }); } The error I'm getting is: metadata_resolver.js:639 Uncaught Error: Can't construct a query for the property "steps" of

Can't get to @ViewChildren in parent component

て烟熏妆下的殇ゞ 提交于 2019-11-30 19:11:58
问题 I am trying to get control over the children instances of a component and can't go past an error. I am trying to follow along the answers from this issue. The parent component Sequence contains children components of SequenceStep . The parent contains the following declaration: @ViewChildren(SequenceStep) steps: QueryList<SequenceStep>; then I am trying to do something about the children: ngAfterViewInit() { this.steps.changes.subscribe(steps => { console.log(steps); }); } The error I'm

How to decorate current state resolve function in UI-Router? Current function isn't invoked

空扰寡人 提交于 2019-11-28 10:28:34
I'm trying to DRY in $stateProvider and prevent adding the same auth function in each resolve. I've created decorator that in each state change would add this function to current state, but auth function isn't invoked, How to fix it or how to workaround discussed issue? app.config(function ($stateProvider, $urlRouterProvider, $provide) { $provide.decorator('$state', function($delegate, $rootScope) { $rootScope.$on('$stateChangeStart', function(event, state, params) { if ($delegate.current === "login" || $delegate.current === "register") { return; } console.log("decorator", $delegate);

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