Académique Documents
Professionnel Documents
Culture Documents
log in or sign up
Search packages
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »
angular2-materialize
public
Readme
0 Dependencies
5 Dependents
76 Versions
Angular2 Materialize
build passing npm v15.1.10 downloads 15k/month license MIT 📦🚀 semantic-release commitizen friendly
prs welcome
This library adds support for the Materialize CSS framework in Angular 2. It is needed to add the dynamic behavior of
Materialize CSS that is using JavaScript rather than plain CSS.
To use the library you need to import it once per project and then use its MaterializeDirective directive for binding it to
any component that needs a dynamic behavior, like collapsible panels, tooltips, etc.
Using angular2-materialize
Start by following the Angular CLI or webpack instructions below to add the required dependencies to your project.
@NgModule({
imports: [
//...
MaterializeModule,
],
//...
})
In your component, use it for dynamic behavior. For example, for collapsible panels:
@Component({
selector: "my-component",
template: `
<ul materialize="collapsible" class="collapsible" data-collapsible="accordion">
<li>
<div class="collapsible-header"><i class="material-icons">filter_drama</i>First</di
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">place</i>Second</div>
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">whatshot</i>Third</div>
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
</li>
</ul>
Apply an empty MaterializeDirective attribute directive for top level components, like forms:
https://www.npmjs.com/package/angular2-materialize 2/8
31/3/2018 angular2-materialize - npm
</div>
</div>
</form>
The MaterializeDirective attribute directive (materialize) accepts any MaterializeCSS initialization call to apply to the
element. The list of supported functions are provided by MaterializeCSS. Examples: collapsible, modal, tooltip,
dropdown, tabs, material_select, sideNav, etc.
The Materialize attribute directive also allows specifying parameters to be passed to the function, but providing a
materializeParams attribute returning an array of params. Use it with a function call or even by inlining the params in
the HTML.
Another useful option is emitting actions on an element. You may want to do that for calling Materialize functions, like
closing a modal dialog or triggering a toast. You can do that by setting the materializeActions attribute, which accepts
an EventEmitter. The emitted events can either be a "string" type action (Materialize function call) or a structure with
action and parameters:
The example below shows how you'd create a modal dialog and use the actions to open or close it.
https://www.npmjs.com/package/angular2-materialize 3/8
31/3/2018 angular2-materialize - npm
For dynamic select elements apply the materializeSelectOptions directive to trigger element updates when the
options list changes:
Go to section apps and find styles array inside it (with only styles.css value by default), add the following line
inside array before any styles:
"../node_modules/materialize-css/dist/css/materialize.css"
Go to section apps and find scripts array inside it, and add the following lines inside array
"../node_modules/jquery/dist/jquery.js",
"../node_modules/hammerjs/hammer.js",
"../node_modules/materialize-css/dist/js/materialize.js"
https://www.npmjs.com/package/angular2-materialize 4/8
31/3/2018 angular2-materialize - npm
MaterializeCSS required jQuery and HammerJS. Check the exact version materialize-css is compatible with:
Import MaterializeCSS programatically, in the same place where you import angular2-materialize module (usually in
your main module, or shared module):
import 'materialize-css';
import { MaterializeModule } from 'angular2-materialize';
https://www.npmjs.com/package/angular2-materialize 5/8
31/3/2018 angular2-materialize - npm
Another thing you would need to confirm is being able to load web fonts properly:
Notice that the url-loader is required for this to work (npm install it).
The following example project is a fork of the angular2-webpack-starter with the addition of angular2-materialize:
InfomediaLtd/angular2-webpack-starter
Keywords
materialize css
install
npm i angular2-materialize
last 7 days
3.500
version license
15.1.10 MIT
https://www.npmjs.com/package/angular2-materialize 6/8
31/3/2018 angular2-materialize - npm
repository
github.com
last publish
6 months ago
collaborators
Documentation
Support / Contact Us
Registry Status
Website Issues
CLI Issues
Security
About npm
https://www.npmjs.com/package/angular2-materialize 7/8
31/3/2018 angular2-materialize - npm
Legal Stu
Terms of Use
Code of Conduct
Package Name Disputes
Privacy Policy
Reporting Abuse
Other policies
https://www.npmjs.com/package/angular2-materialize 8/8