Skip to content
35 changes: 28 additions & 7 deletions packages/angular/test/apps/ng14/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/angular/test/apps/ng14/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@ionic/angular-server": "^6.1.15",
"core-js": "^2.6.11",
"express": "^4.15.2",
"ionicons": "^6.0.4",
"ionicons": "7.1.3-dev.11692630068.1f5f09ee",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"typescript-eslint-language-service": "^4.1.5",
Expand Down
35 changes: 28 additions & 7 deletions packages/angular/test/apps/ng15/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/angular/test/apps/ng15/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@nguniversal/express-engine": "^15.0.0",
"core-js": "^2.6.11",
"express": "^4.15.2",
"ionicons": "^6.0.4",
"ionicons": "7.1.3-dev.11692630068.1f5f09ee",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"typescript-eslint-language-service": "^4.1.5",
Expand Down
67 changes: 60 additions & 7 deletions packages/angular/test/apps/ng16/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/angular/test/apps/ng16/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@nguniversal/express-engine": "^16.0.0",
"core-js": "^2.6.11",
"express": "^4.15.2",
"ionicons": "^7.0.4",
"ionicons": "7.1.3-dev.11692630068.1f5f09ee",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"typescript-eslint-language-service": "^4.1.5",
Expand Down
20 changes: 20 additions & 0 deletions packages/angular/test/base/e2e/src/standalone/icon.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe('Icons', () => {
it('should render an icon', () => {
cy.visit('/standalone/icon');

cy.get('ion-icon#icon-string').shadow().find('svg').should('exist');
cy.get('ion-icon#icon-binding').shadow().find('svg').should('exist');
});

it('should render an icon on iOS mode', () => {
cy.visit('/standalone/icon?ionic:mode=ios');

cy.get('ion-icon#icon-mode').shadow().find('svg').should('exist');
});

it('should render an icon on MD mode', () => {
cy.visit('/standalone/icon?ionic:mode=md');

cy.get('ion-icon#icon-mode').shadow().find('svg').should('exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const routes: Routes = [
{ path: 'nav', loadComponent: () => import('../nav/nav.component').then(c => c.NavComponent) },
{ path: 'providers', loadComponent: () => import('../providers/providers.component').then(c => c.ProvidersComponent) },
{ path: 'overlay-controllers', loadComponent: () => import('../overlay-controllers/overlay-controllers.component').then(c => c.OverlayControllersComponent) },
{ path: 'button', loadComponent: () => import('../button/button.component').then(c => c.ButtonComponent) }
{ path: 'button', loadComponent: () => import('../button/button.component').then(c => c.ButtonComponent) },
{ path: 'icon', loadComponent: () => import('../icon/icon.component').then(c => c.IconComponent) },
]
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div>
Icon Name: <ion-icon id="icon-string" name="logo-ionic"></ion-icon><br />
Icon Name Binding: <ion-icon id="icon-binding" [name]="iconName"></ion-icon> <button id="change-icon" (click)="changeIcon()">Change Icon Binding</button><br />
iOS/MD: <ion-icon id="icon-mode" ios="logo-apple" md="logo-android"></ion-icon><br />
iOS/MD Binding: <ion-icon id="icon-mode-binding" [ios]="iosIcon" [md]="mdIcon"></ion-icon> <button id="change-mode-icon" (click)="changeModeIcon()">Change Icon Binding</button><br />
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Component } from '@angular/core';
import { IonIcon } from '@ionic/angular/standalone';
import { logoIonic, logoIonitron, logoApple, logoAndroid } from 'ionicons/icons';
import { addIcons } from 'ionicons';

addIcons({ logoIonic, logoIonitron, logoApple, logoAndroid });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Played with this locally, everything looks/works good 👍

It seems to work consistently if you have this outside the class or within the constructor. Does not work (too late in the execution cycle, after connectedCallback fires) if you try to add icons in the ngOnInit lifecycle.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! We'll want to note this in the docs


@Component({
selector: 'app-icon',
templateUrl: './icon.component.html',
standalone: true,
imports: [IonIcon],
})
export class IconComponent {
iconName: string = 'logo-ionic';
iosIcon: string = 'logo-apple';
mdIcon: string = 'logo-android';

changeIcon() {
this.iconName = this.iconName === 'logo-ionic' ? 'logo-apple' : 'logo-ionic';
}

changeModeIcon() {
this.iosIcon = this.iosIcon === 'logo-apple' ? 'logo-ionic' : 'logo-apple';
this.mdIcon = this.mdIcon === 'logo-android' ? 'logo-ionitron' : 'logo-android';
}
}