Live presentation: Ionic’s Security Trifecta: Mobile App Security Made Easy

Docsv3
v2v3 (RC)All Releases
  • Getting Started
    • Introduction
    • Environment Setup
    • Installation
    • Using with Ionic Framework
  • Basics
    • Development Workflow
    • Using Plugins
    • Native Project Configuration
  • Upgrade Guides
    • Upgrading to 3.0
    • Upgrading to 2.0
    • Upgrading to 1.1
    • Upgrading plugins to 3.0
  • Cordova/PhoneGap
    • Overview
    • Migration Strategy
    • Cordova to Capacitor Migration
  • Concepts
    • Ads
    • Angular
    • CI/CD
    • Deep Links
    • Deploying and Updating
    • In App Purchases
    • Live Reload
    • Push Notifications - Firebase
    • React Hooks
    • Screen Orientation
    • Security
    • Splash Screens and Icons
    • Storage
    • Community Guides
  • iOS
    • Getting Started
    • Configuration
    • Custom Native Code
    • Deploying to App Store
    • Troubleshooting
  • Android
    • Getting Started
    • Configuration
    • Custom Native Code
    • Deploying to Google Play
    • Troubleshooting
  • Web/PWA
    • Getting Started
    • Progressive Web Apps
    • PWA Elements
  • Reference
    • Config
    • Core APIs
    • Plugin APIs ->
    • CLI ->
DocsPluginsCLI
CommunityBlogEnterprise
Install

Using Angular with Capacitor

NgZone

Capacitor plugin event listeners run outside of Angular’s NgZone execution context. Contain handler logic within an NgZone.run block to ensure Angular’s change detection is triggered:

constructor(private ngZone: NgZone) { }

async ngOnInit() {
  Network.addListener("networkStatusChange", (status) => {
    this.ngZone.run(() => {
      // This code will run in Angular's execution context
      this.networkStatus = status.connected ? "Online" : "Offline";
    });
  });
}
Previous
<- Ads
Next
CI/CD ->
Contribute ->
Contents
  • NgZone
Submit an edit