Skip to content

Commit 8d6ce1c

Browse files
authored
feat(schematics): use Ionic standalone components (#504)
resolves #500
1 parent 2e452a1 commit 8d6ce1c

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

packages/schematics/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2-
import { IonicModule } from '@ionic/angular';
1+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';<% if(!standalone) {%>
2+
import { IonicModule } from '@ionic/angular';<%} %>
33

44
import { <%= classify(name) %><%= classify(type) %> } from './<%= dasherize(name) %>.<%= dasherize(type) %>';
55

@@ -8,9 +8,10 @@ describe('<%= classify(name) %><%= classify(type) %>', () => {
88
let fixture: ComponentFixture<<%= classify(name) %><%= classify(type) %>>;
99

1010
beforeEach(waitForAsync(() => {
11-
TestBed.configureTestingModule({
11+
TestBed.configureTestingModule({<% if(!standalone) {%>
1212
declarations: [ <%= classify(name) %><%= classify(type) %> ],
13-
imports: [IonicModule.forRoot()]
13+
imports: [IonicModule.forRoot()]<%} %><% if(standalone) {%>
14+
imports: [<%= classify(name) %><%= classify(type) %>],<%} %>
1415
}).compileComponents();
1516

1617
fixture = TestBed.createComponent(<%= classify(name) %><%= classify(type) %>);

packages/schematics/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { Component, OnInit } from '@angular/core';
33
@Component({
44
selector: '<%= selector %>',
55
templateUrl: './<%= dasherize(name) %>.<%= dasherize(type) %>.html',
6-
styleUrls: ['./<%= dasherize(name) %>.<%= dasherize(type) %>.<%= styleext %>'],
6+
styleUrls: ['./<%= dasherize(name) %>.<%= dasherize(type) %>.<%= styleext %>'],<% if(standalone) {%>
7+
standalone: true,<%} %>
78
})
89
export class <%= classify(name) %><%= classify(type) %> implements OnInit {
910

packages/schematics/page/files/__name@dasherize@if-flat__/__name@dasherize__.page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { Component, OnInit } from '@angular/core';<% if(routePath) { %>
22
import { ActivatedRoute, Params } from '@angular/router';<% } %><% if(standalone) {%>
33
import { CommonModule } from '@angular/common';
44
import { FormsModule } from '@angular/forms';
5-
import { IonicModule } from '@ionic/angular';<%} %>
5+
import { IonContent, IonHeader, IonTitle, IonToolbar } from '@ionic/angular/standalone';<%} %>
66

77
@Component({
88
selector: '<%= selector %>',
99
templateUrl: './<%= dasherize(name) %>.page.html',
1010
styleUrls: ['./<%= dasherize(name) %>.page.<%= styleext %>'],<% if(standalone) {%>
1111
standalone: true,
12-
imports: [IonicModule, CommonModule, FormsModule]<%} %>
12+
imports: [IonContent, IonHeader, IonTitle, IonToolbar, CommonModule, FormsModule]<%} %>
1313
})
1414
export class <%= classify(name) %>Page implements OnInit {<% if(routePath) { %>
1515

0 commit comments

Comments
 (0)