ngx-image-carousel v0.0.7
NgImageCarousel
This project was generated with Angular CLI version 11.2.12.
Development server
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Code scaffolding
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Build
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Running unit tests
Run ng test
to execute the unit tests via Karma.
Running end-to-end tests
Run ng e2e
to execute the end-to-end tests via Protractor.
Further help
To get more help on the Angular CLI use ng help
or go check out the Angular CLI Overview and Command Reference page.
Creating carousel library in Angular
Step 1: Install nodejs and angular cli i.e nodejs you can install from https://nodejs.org/en/download/ and then
npm i -g @angular/cli
Step 2: Create a new workspace for your Angular component project. Create a new Angular workspace with the command. ng new --create-application=false
Then navigate into the workspace folder with the command cd
The --create-application=false flag prevents a default Angular application project from being created, because you'll be creating a library project for your component. So For Carousel one i choose my workspace name is ngImageCarousel ng new ngImageCarousel --create-application=false
Then navigate to folder cd ngImageCarousel
Step 3: Create a new Angular library project Angular library projects are used for developing reusable components and services that can be published as npm packages. Create a new library project for your component with the command ng generate library
Eg: In our cases I generate a library with name nggx-image-carousel ng generate library ngx-image-carousel
Step 4: Update the Angular component with your code Replace the generated Angular component with the custom component that you want to publish to npm.
Step 5: Update required dependencies(if any): In ng-package.json file add this command is use to allow non peer dependencies "allowedNonPeerDependencies": "."
In Package.json file of our Library folder add this "dependencies": { "tslib": "^2.0.0", "@ng-bootstrap/ng-bootstrap": "^9.1.0", "@angular/localize": "^11.2.13" },
Step 6:Build your Angular component Run the below command from your workspace folder to build your component, the output files are created in the dist/ folder. ng build --prod
Eg ng build ngx-image-carousel -prod
Step 7: Register in npm Register yourself if you are not registered click on the below link https://www.npmjs.com/
Step 8: Now login to npm from cmd It will prompt for username , password and email. npm login
Step 9:Publish your Angular component to npm Navigate to the project dist folder with the command cd dist/
Run the below command to publish the component the npm. npm publish
Step-10 : To run our library Create a new Angular project and add this script into your index file Its a bootstrap CDN
install our library by using command npm i ngx-image-carousel
Finally Publishing our library to npm done. Thank you