ng-directives
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

NgDirectives

This library is Ivy Compatible and is tested against an Angular 9 app.

  • A collection of directives to be used with Angular app to give additional functionality which will help to avoid wrong inputs
  • It is developed using Angular >=9.0.0 and its newly introduced ng g library schematics.
  • This library is part of MatTypeahead project and it is generated with Angular CLI version 9.0.6.
  • Library location: projects/ng-directives directory of this repository.

Examples/Demo

  • A simple Example can be found under src/app directory of this repository.

Installation

npm i ng-directives


import { NgDirectivesModule } from "ng-directives";
selector: numberOnly for number only validation

Usage

  1. Register the NgDirectivesModule in your app module.

import { NgDirectivesModule } from "ng-directives";

import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
 
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { NgDirectivesModule } from "ng-directives";
 
@NgModule({
 declarations: [AppComponent],
 imports: [BrowserModule, AppRoutingModule, NgDirectivesModule],
 providers: [],
 bootstrap: [AppComponent],
})
export class AppModule {}
 
  1. Use the directive (NgDirectives) in your component.
import { Component } from "@angular/core";
 
@Component({
  selector: "ng-dir-root",
  template: `<form>
  <div class="form-group">
    <label for="age">Age</label>
    <input numberOnly type="text" class="form-control" id="age">
  </div>
</form>
 
`,
  styleUrls: ['./app.component.css']
})
export class AppComponent  {
  
}

Running the example in local env

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

Build the NgDirectives module

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

Credits

I want to thanks entire Angular team for creating this awesome framework.

Package Sidebar

Install

npm i ng-directives

Weekly Downloads

27

Version

0.0.3

License

none

Unpacked Size

94.3 kB

Total Files

29

Last publish

Collaborators

  • nitin27may