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:
- Install npm install -g modernizr
- Downloaded modernizr-custom.js with only form inputs checked.
- Downloaded modernizr-config.json
- 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.
Follow the steps -
Place the type definition of Modernizr into your project folder.
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.
You would just need to include the Modenrizr file in your page, above any of your angular code. It will register itself on the page, and you will be able to access the global Modernizr
object. No further integration should be nessecary
Import modernizr like below in your ts file and use it :)
import * as Modernizr from 'modernizr
';
来源:https://stackoverflow.com/questions/38107629/angular2-with-modernizr