Skip to content

Commit

Permalink
fix(angular): makes field to be optional argument
Browse files Browse the repository at this point in the history
Relates to #126
  • Loading branch information
stalniy committed Nov 11, 2018
1 parent cdb5d01 commit a3eec63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/casl-angular/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules/
.*
coverage.lcov
coverage
tsconfig.json
6 changes: 3 additions & 3 deletions packages/casl-angular/src/can.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ export class CanPipe {
constructor(protected ability: Ability, protected cd: ChangeDetectorRef) {
}

transform(resource: any, action: string, field: string) {
transform(resource: any, action: string, field?: string) {
if (this.unsubscribeFromAbility === noop) {
this.unsubscribeFromAbility = this.ability.on('updated', () => this.cd.markForCheck());
}

return this.can(action, resource, field);
}

can(...args: [string, any, string?]) {
return this.ability.can(...args);
can(action: string, subject: any, field?: string) {
return this.ability.can(action, subject, field);
}

ngOnDestroy() {
Expand Down

0 comments on commit a3eec63

Please sign in to comment.