Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 with modernizr

I am learning angular2 and building my own custom components using ng2-bootstrap. I want to use modernizer to detect form input which are natively supported by browser.

I am using webpack for building my project.I have successfully configured that.

What I did till now is:


  1. Install npm install -g modernizr
  2. Downloaded modernizr-custom.js with only form inputs checked.
  3. Downloaded modernizr-config.json
  4. I did modernizr -c modernizr-config.json to get a js file.ow to use

I am not sure how to Modernizr.inputtypes.date in my own custom component?How we can access Modernizr variable in my component?

Any help is much appreciated.

like image 880
Som Avatar asked Jun 29 '16 18:06

Som


2 Answers

Follow the steps:

  1. Place the type definition of Modernizr into your project folder.

  2. Place the modernizr.js in your project and access it within any component using relative path like:

    import './Lib/modernizr.js';
    

Done. You should be able to use the Modernizr to detect browser feature support.

like image 85
Ram Avatar answered Nov 13 '22 02:11

Ram


Import modernizr like below in your ts file and use it :)

import * as Modernizr from 'modernizr';

like image 37
Shreeketh K Avatar answered Nov 13 '22 01:11

Shreeketh K