Reputation: 499
I'm working in angular project with own CSS which is almost done now i want to use ionic framework with cordova in my project. I tried but it is not working .
Is there any way and step by step process to add ionic framework in my existing Angular 4 project.
can i have any link or guidance to reach my goal.
Thanks in advance
Upvotes: 8
Views: 10984
Reputation: 2943
Below Solution work for me: (I've added ionic in angular project with below steps)
ionic init
ng add @ionic/angular
To resolve above error follow below steps:
Open angular.json file:
change below properties
2.1 Before: outputPath: 'dist/<<project_name>>/browser' After: outputPath: 'www'
2.2 Replace <<PROJECT_NAME>> with "app". For Example: Before: 'my_angular_project:build:production' AFTER: 'app:build:production'
In case if you are facing scrolling issue
In project_name>src>style.css add below css properties
html, body {
overflow: auto !important;
}
body::-webkit-scrollbar {
display: none !important;
}
Upvotes: 1
Reputation: 4871
To use Ionic components in an existing Angular project. Two easy steps:
Add schemas: [ CUSTOM_ELEMENTS_SCHEMA ] to your module (app.module.ts) Like so:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule],
declarations: [ AppComponent],
bootstrap: [ AppComponent ],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule { }
Add a link to the CDN in your index.html
<script src="https://unpkg.com/@ionic/[email protected]/dist/ionic.js"></script>
Source: https://medium.com/lacolaco-blog/use-ionic-components-as-web-components-in-angular-2eee2178d5be
Upvotes: 0
Reputation: 1600
There is a schematic command for adding ionic to an existing angular project:
ng add @ionic/angular
Upvotes: 14
Reputation: 5747
I have documented my approach here:
https://stack247.wordpress.com/2019/03/11/integrate-ionic-in-existing-angular-project/
This applies to
Essentially, these are the steps:
The step includes creating a new project using Ionic CLI, I'm going to refer it as Ionic project while my original Angular project as, well, Angular project.
ionic start project-name blank
ionic.config.json
from Ionic project to Angular project.angular.json
from Ionic project to Angular project.
angular.json
, make that necessary changes in the Angular project after the copy.projects/app/architect/**/options/styles
from Angular project's angular.json
prior to copy.package.json
from Ionic project to Angular project.
package.json
(npm scripts, etc), make that necessary changes in the Angular project after the copy.dependencies
and devDependencies
.package-lock.json
file and node_modules
folder. These should be located in root of the project.npm install
// Test run with Ionic
ionic serve
// Test run with Angular
ng serve --open
// For Android
ionic cordova prepare android
// For iOS
//ionic cordova prepare ios
Upvotes: 11