Fix node-permission directive for delete (#2730)

This commit is contained in:
Popovics András
2017-11-24 18:04:07 +00:00
committed by Eugenio Romano
parent 754e02625e
commit 78cd7ad84b
3 changed files with 13 additions and 6 deletions

View File

@@ -90,16 +90,23 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
### Defining your components as an EXTENDIBLE_COMPONENT parent component ### Defining your components as an EXTENDIBLE_COMPONENT parent component
The directive will look up the component in the dependency injection tree, up to at most one step above the current DI level (@Host). Because of this, you have to provide your component with forward referencing as the EXTENDIBLE_COMPONENT. The directive will look up the component in the dependency injection tree, up to the @Host() component.
> "The host component is typically the component requesting the dependency. **But when this component is projected into a parent component, that parent component becomes the host.**"
- because of this, you have to provide your component with forward referencing as the EXTENDIBLE_COMPONENT.
- because of the emphasized second sentence you have to provide your component as a viewProvider.
```js ```js
import { EXTENDIBLE_COMPONENT } from 'ng2-alfresco-core'; import { EXTENDIBLE_COMPONENT } from 'ng2-alfresco-core';
@Component({ @Component({
... ...
providers: [ viewProviders: [
{ provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadDragAreaComponent)} { provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadDragAreaComponent)}
] ]
}) })
export class UploadDragAreaComponent implements NodePermissionSubject { ... } export class UploadDragAreaComponent implements NodePermissionSubject { ... }
``` ```
**Notice the usage of viewProviders (instead of providers)! This part is very important, especially if you want to use this directive on a transcluded component!**

View File

@@ -46,7 +46,7 @@ import 'rxjs/add/observable/throw';
selector: 'adf-upload-button', selector: 'adf-upload-button',
templateUrl: './upload-button.component.html', templateUrl: './upload-button.component.html',
styleUrls: ['./upload-button.component.scss'], styleUrls: ['./upload-button.component.scss'],
providers: [ viewProviders: [
{ provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadButtonComponent) } { provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadButtonComponent) }
], ],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None

View File

@@ -31,7 +31,7 @@ import { Component, EventEmitter, forwardRef, Input, Output, ViewEncapsulation }
selector: 'adf-upload-drag-area', selector: 'adf-upload-drag-area',
templateUrl: './upload-drag-area.component.html', templateUrl: './upload-drag-area.component.html',
styleUrls: ['./upload-drag-area.component.css'], styleUrls: ['./upload-drag-area.component.css'],
providers: [ viewProviders: [
{ provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadDragAreaComponent)} { provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadDragAreaComponent)}
], ],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None