question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: Angular 14 Standalone Components

See original GitHub issue

Prerequisites

Describe the Feature Request

Angular 14 introduces the ability to use standalone components, without having to declare them on an NgModule. This feature is used for rendering components within a parent component, as well as for lazy loading a standalone component on a route, instead of using a routing module.

Standalone components encompass all declarations (pipes, directives and components).

As of Angular 14, standalone components are a dev preview feature. They are also not backwards compatible with older versions of Angular. This means for Ionic to add support for standalone components, Ionic would have to remove support for Angular 13 and lower.

If you are wanting to experiment with an Angular 14 project and Ionic using standalone components, the following dev-build is available:

6.1.7-dev.11654279011.1b971e3e

For an example Ionic application on Angular 14, you can clone: https://github.com/sean-perkins/angular-14-demo. Remember to install the available dev-build.

Screen Shot 2022-06-03 at 2 02 40 PM

Describe the Use Case

Ionic developers should be able to use the following code:

{
   path: 'standalone',
   loadComponent: () => import('./standalone.component').then(m => m.StandaloneComponent)
 }

To create a route of /standalone that renders the StandaloneComponent inside of the ion-router-outlet.

Describe Preferred Solution

No response

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:14
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
sean-perkinscommented, Jun 22, 2022

After some initial investigation work, I have been able to identify a pattern which would allow Ionic to add support for standalone components with supporting previous versions of Angular.

With the introduction of a new property on ion-router-outlet and ion-tabs, developers could pass in the required EnvironmentInjector to our routing implementations.

For example, the implementation pattern would look like:

import { EnvironmentInjector } from '@angular/core';
@Component({})
export class ExampleComponent {
  constructor(public environmentInjector: EnvironmentInjector) {}
}
<ion-router-outlet [environmentInjector]="environmentInjector"></ion-router-outlet>

This would then allow developers to use the new syntax for route definitions to use standalone components. This would be an opt-in feature for Angular 14+ and only required until ~ Ionic 8 release, which would drop support for Angular 13. It would only be required if you wanted to use standalone components with routing in Ionic.

Because we would be supporting an experimental API from Angular, we would reserve the right to remove/change that API at any time (between minor or major releases).

3reactions
mackelitocommented, Aug 22, 2022

When will we be able to use standalone components? is there a rough ETA?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting started with standalone components - Angular
Standalone components provide a simplified way to build Angular applications. Standalone components, directives, and pipes aim to streamline the authoring ...
Read more >
Angular 14—Introducing Standalone Components - Telerik
A standalone component is a type of component which is not part of any Angular module. Prior to Angular 14, usually when you...
Read more >
Angular 14 arrives with typed forms, standalone components
Standalone components promise to streamline the development of Angular apps by reducing the need for NgModules.
Read more >
Standalone Components in Angular 15 - Matt
feat (@schematics/angular): remove environment files in new applications This commit removes the usage of environment files and `fileReplacements ...
Read more >
Angular Standalone Components: Welcome to a World ...
The powers that be have spoken, and based on the community's feedback, the often maligned NgModule is on its way out (partially). Angular...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found