Setup the custom component in the Angular Material2 using gulp.

Hi Readers,

I am happy to let you know that you can create your own component easily in the material2 with gulp.

But how can you do it,  hmmm.... well this question bothered me for almost two weeks and successfully we (Pradeep my teammate and I) were able to tackle it.

Now i want to share this with you so that you can create your own component and start the site quickly.

Lets get dive together to dig the Angular Material2 repo to create a custom component.

Follow the below steps to create a custom component named Material Text:
      This is not the component which is contributable but

1. Set up the Angular Material2 in your local. (Instruction to do it is in my Previous Blog).
2. When you are successfully setup with the running project. Now create a folder for the custom component in the /src/lib/ folder this is the folder which will be compiled in the /dist/@angular-material2 folder after build.

3. Add the appropriate files in this folder. I have already added so you can clone my Repo and see the files.
Clone URL: https://github.com/prashant162/GulpMaterial2.git



4. when you have cloned the repo you will see the appropriate files in the /src/lib/text folder.
5. Now lets add the same folder in the /src/demo-app folder. This is the folder which will be compiled in the /dist folder.
6. Add the appropriate files in the /src/demo-app/text folder, you can take reference from my repo that you cloned in the step3.
     
 Please open the files and read the contents for the files yourself so that you can understand the  meaning of each file and know what is for what.

7. Now add your component in the demo-app.ts to bootstrap it.
  7.1 Import your module as "import {TextDemo} from './text/text-demo';" at the top
  7.2 Now declare you component in the Declartion Array in the same file:



8. Okay lets test if we are able to build or not, actually we should be. So lets run the command "gulp build:devapp" from the root of the project.

9. If everything is okay you will be able to see the text folder that you created in the /src/lib folder in the /dist/@angular-material2 folder. Also, the folder that you created in the /src/deom-app folder will be visible in the /dist folder.

10. Now how the system will get to know that a new component has been added... So, for it lets add the entry for our component in the /src/lib/system-config-spec.ts and /src/demo-app/system-config.ts file in the "const component" array:




11. Now lets add our component in the routing so that we can show it by clicking in the sidebar navigation.

12. Import our custom component in the route.ts in the /src/demo-app/demo-app/routes.ts file, and add the entry in the "export const DEMO_APP_ROUTES: Routes" array like other components have.

13. Now to show it in the side navigation add the entry in the /src/demo-app/demo-app/demo-app.html as "<a md-list-item [routerLink]="['text']">Custom Text Component</a>" under the "<md-nav-list>" tag.

14. We are now one step far to see our component on the browser. Before there is one more place where we have to call the component. Lets add the entry in the /src/lib/all/all.ts folder:

   14.1  Import our component in the all.ts like others component have been imported.
   14.2 Make the entry in the "const MATERIAL_MODULES" array in the same file.
   14.3 Access the function that you created in the /src/lib/text by putting the entry "MdTextModule.forRoot()," in the @NgModule({
  imports: [ ] })  array.

15. Now lets do the "gulp build:devapp" and then "gulp serve:devapp".
16. Hurray... you will be able to see you custom component at the left navigation click on it and you will see it on your screen.


PLEASE LEAVE YOUR COMMENT BELOW IF YOU HAVE ANY QUESTION OR DOUBT, AND DO A SHARE IF YOU LIKE.

Thank you reader!!

Setting angular material2 in your local.

I would like to tell you that angular material2 is now moving from Angular CLI to gulp.

May be that Angular CLI will use the Webpack so it may be the reason that it will be not easy for material to setup using the CLI. They may be back after completing with webpack and the consistencies.


If you want to setup the material2 just simply follow the steps below:

1. The node version should be atleast 5.5.0
2. Install gulp by npm install -g gulp
3. Fork the repo angular Material2
4. Clone the forked repo in your local.
5. Now do the npm install.
6. To build the components type gulp build:devapp (for dev mode), to build the components in the release mode type gulp build:release 
7. To run it on the local sever type gulp serve:devapp
8.  Now type localhost:4200 in your browser, you will be able to see the components in the browser.

This documentation is created on: 8-sept-2016

It may be overhooked if other releases are out for material or gulp or other dependencies.

Please leave your comments if you feel any suggestions, appreciation or modification in the blog.

Creating Solr core for sitecore using command prompt

We setup the solr cores using command “C:\solr8985\sc103solr-8.11.2\bin>solr.cmd create -c sitecore_sxa_web_index -d sitecore_configset” ...