Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation update #57

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
53 changes: 34 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
# Node
node_modules/*
npm-debug.log
# See http://help.github.com/ignore-files/ for more about ignoring files.

# TypeScript
src/*.js
src/*.map
src/*.d.ts
# compiled output
/dist
/tmp
/out-tsc

# JetBrains
.idea
# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.settings
.idea/*
*.iml
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# VS Code
# IDE - VSCode
.vscode/*

# Windows
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
Desktop.ini

# Mac
.DS_Store
**/.DS_Store
# JetBrains
.idea
.project
.settings
.idea/*
*.iml

# Ngc generated files
**/*.ngfactory.ts

# Build files
dist/*
# Tests
coverage/*
38 changes: 0 additions & 38 deletions .npmignore

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
sudo: true
node_js:
- '6.11.2'
- '8.11.1'

script: npm run test:single

Expand Down
7 changes: 0 additions & 7 deletions .yo-rc.json

This file was deleted.

73 changes: 65 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,54 @@ const appRoutes: Routes = [
```
----------------------------

### Unit Testing of Component ( ByPassing Directive )

```typescript
import { Component, OnInit } from '@angular/core';
import { NgxPermissionsService } from 'ngx-permissions';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {

title = 'app';

constructor(private permissionsService: NgxPermissionsService) {}

ngOnInit(): void {
const perm = ["ADMIN", "EDITOR"];
this.permissionsService.loadPermissions(perm);
}
}
```
```html
<div *ngxPermissionOnly=["ADMIN"]>
<p class="pull-right">Hey! You can see me.<p>
</div>
```

```typescript
import { NgxPermissionsAllowStubModule } from 'ngx-permissions';
describe('AppComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
NgxPermissionsAllowStubModule,
],
schemas: [NO_ERRORS_SCHEMA],
});
fixture = TestBed.createComponent(AppComponent);

});

it('can find the p element and bypass the directive', () => {
const element = fixture.nativeElement;
expect(element.getElementsByClassName('pull-right').length).toBe(1);
});
})
```

## Common use cases

Expand Down Expand Up @@ -1187,17 +1235,26 @@ let routes = [
| --- |
## Development

To generate all `*.js`, `*.d.ts` and `*.metadata.json` files:
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.0.

```bash
$ npm run build
```

To lint all `*.ts` files:
### Demo App

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

### Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.

### Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

### Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).


```bash
$ npm run lint
```
## Thank You

`Thank You for using the library and support. HAVE A GREAT DAY!`
Expand Down
Loading