Friday, 21 April 2017

Angular 2 with Materialize

I am trying to run Materialize on my Angular 2 project but I think I am having trouble with the sorting of JS files in the index.html file.

I am using npm to install the node modules for Angular 2. I used the following commands to import the files needed for Angular 2 and materializecss

npm install
npm install materialize-css

Index.html

<!DOCTYPE html>
<html>

<head lang="en">
     <base href="/">
    <title>Angular 2 Project</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">


    <link href="app/app.component.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/css/materialize.min.css">
    <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

    <!-- Polyfill(s) for older browsers -->
    <script src="node_modules/core-js/client/shim.min.js"></script>
    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/js/materialize.min.js"></script>
    <!-- Configure SystemJS -->
    <script src="systemjs.config.js"></script>

    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
</head>

<body>
    <pm-app>Loading App...</pm-app>
</body>

</html>

Main.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
import "materialize-css";
import "angular2-materialize";

For app.component.css I am using the MaterializeCSS min.css content

I am using Visual Studio Code to compile this project.

Note I am trying to convert this project from bootstrap to materialize. If need be, I can start a new project and just import all of the code needed. I'm not afraid of hard work :)

Thanks!



via Eddie Maiale

No comments:

Post a Comment