ngx-simpler-youtube-validator
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

NgxSimplerYoutubeValidator

How to:

  1. import module
import { 
    NgxSimplerYoutubeValidatorModule 
} from 'ngx-simpler-youtube-validator';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    NgxSimplerYoutubeValidatorModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  1. add youtube validatior directive to exist formControl
@Component({
  selector: 'app-root',
  template: `
    <div>
      <h1>Hello World</h1>

      <div>
        <form [formGroup]="form">
          <input
            type="text"
            [formControl]="url"
            [isYoutubeUrl]="true" <-- indicator that you want validate url 
                                        or youtube id, default is false
            [forceFixUrl]="true" <-- if true and isYoutubeUrl, 
                                        then your input will be updated become 
                                        proper format.
                                        ex:
                                            from: https://www.youtube.com/watch?v=w2y715XAmso&list=RDLlldWeUmwVY&index=2
                                            to: https://www.youtube.com/watch?v=w2y715XAmso
            simplerYoutubeValidator> <-- this

          <div>
            <button [disabled]="!form.valid">
              Submit
            </button>
          </div>
        </form>
      </div>
    </div>
  `,
})
export class AppComponent implements OnInit { }
  1. done :)

Contributes:

Readme

Keywords

none

Package Sidebar

Install

npm i ngx-simpler-youtube-validator

Weekly Downloads

4

Version

0.0.3

License

MIT

Unpacked Size

52.7 kB

Total Files

19

Last publish

Collaborators

  • agung96tm