Skip to main content

Angular CLI Command List


These commands are use for create a project , project component, services, models etc in angular. The list of all command and there information are availabel here.


Setup CLI


We need to install CLI first of all open command prompt and write down given command . It will automaticaly install Angular CLI in system. Before this you need Node.js Installed in your system. Go to node official website simply downlod the installer and run on your system. After that this command will work for you.


npm install @angular/cli -g


Create new angular projects


ng new: Command


This command is user to create a new project with angular CLI.


ng new project name


Example


ng new project-1


--dry run instruction for CLI


Simply when we don’t know what a command do in our system. We can use –dry run instruction with command it will show its working in console but don’t do anything in system.


Example


ng new project –dry run


--skip-install instruction


This instruction is givern for that when you don’t want to install external dependencies right after the creation of new project.


Example


ng new project-1 --skip-install


You can install all skiped dependencies also using npm install command on your root folder


npm install


--skip-tests instruction


When we create project using CLI it create a .spec.ts file automatcly. It do same for the components also. This file required only for testing purpose sometime you don’t want it to generate to do so we use this instruction along with the command


Example


ng new project-1 --skip-tests


This command will create a angular project. It will create all files expact .spec.ts file. By using this you can save a lot of space on your drive.


Generate component using angular CLI


In a angular project there is a lot of section of project which is called components. It depends on each other. We generate these components using CLI later we manage to communicate them each other to get result.
To generate these components we use these command


ng generate component [component-name]


Example


ng generate component page-1


We can minimize these code like


ng g c page-1


here g for generate c for component


ng serve


This command is use for run project for example go to your project root folder and type this command in terminal


ng serve


It will compile your project and run on default browser.


Ng build


This command us use to creat build for deploy your project on web-server.
As you know angular CLI create devide project into components, serveces, pipes, and models. We can not deploye all these filse same as it is.
Angular CLI create a finel build of project where all compiled code are stored.
To create this build we use ng build command. By default CLI store build in dist folder. To create buld you have to go in your project root folder and run this command in terminal


Example


ng build


It will compile your project and stored in dist folder. But build is not fully finel build this is in development mode it still use some development time variable.
To create a fully finel build we use –prod instructin with build command.


Example


ng build --prod

Comments

Popular posts from this blog

Wo-commerce sidebar navigation

There is Plus Minus Image you can change it in your own code

How to add attribute in input type onload

Add this script this will target your input type submit and set an attribute on it when page load. <script> function functionAddAttribute(){     $("input:submit").attr("accesskey","g"); }; window.onload = functionAddAttribute; </script> <noscript>Your browser does not support JavaScript!</noscript> This is html <input type="submit" value="this is button" />

HOW TO IMPLEMENT ADAPTIVE IMAGE IN WORDPRESS

If you don't know about Adaptive image please Read my last artical. STEP:1 COPY .htaccess , Adaptive-image.php, ai-cookie.php, DS_Store file in your root directory STEP 2: CREATE folder in wp-contant/uploads/adaptive/ai-cache if .htaccess file already exist then pest this code in it but be carefull take its backup CODE #START Adaptive-Images #Add any directories you wish to omit from the Adaptive-Images process on a new line. #Omit plugins, wp-includes and wp-admin content. RewriteCond %{REQUEST_URI} !wp-content/plugins RewriteCond %{REQUEST_URI} !wp-includes RewriteCond %{REQUEST_URI} !wp-admin #Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories #to adaptive-images.php so we can select appropriately sized versions RewriteRule .(?:jpe?g|gif|png)$ adaptive-images.php #END Adaptive-Images UNDER # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On STEP3: Open Adaptive-image.php change with it $cache_path    = "wp-content/upl...