Giter VIP home page Giter VIP logo

tutorial-photo-gallery-angular's Introduction

Build Your First Ionic App: Photo Gallery (Ionic Angular and Capacitor)

Get started with Ionic by building a photo gallery app that runs on iOS, Android, and the web - with just one codebase. This is the complete project referenced in the "Your First App: Angular" guide. Follow along to create a complete CRUD (create-read-update-delete) experience.

Powered by Ionic Angular (web app) and Capacitor (native app runtime).

How It Works

After the user navigates to Tab 2 (Photos), they can tap/click on the camera button to open up the device's camera. After taking or selecting a photo, it's stored permanently into the device's filesystem. When the user reopens the app at a later time, the photo images are loaded from the filesystem and displayed again in the gallery. The user can tap on a photo to be presented with the option to remove the photo.

Feature Overview

Project Structure

  • Tab2 (Photos) (src/app/tab2/): Photo Gallery UI and basic logic.
  • PhotoService (src/app/services/photo.service.ts): Logic encapsulating Capacitor APIs, including Camera, Filesystem, and Preferences.

How to Run

Note: It's highly recommended to follow along with the tutorial guide, which goes into more depth, but this is the fastest way to run the app.

  1. Install Ionic if needed: npm install -g @ionic/cli.
  2. Clone this repository.
  3. In a terminal, change directory into the repo: cd photo-gallery-capacitor-ng.
  4. Install all packages: npm install.
  5. Run on the web: ionic serve.
  6. Run on iOS or Android: See here.

tutorial-photo-gallery-angular's People

Contributors

dependabot[bot] avatar dotnetkow avatar jcesarmobile avatar liamdebeasi avatar mhartington avatar mlynch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tutorial-photo-gallery-angular's Issues

Service no longer working SDK30

Although great, an app in which I use the service is now broken, as it doesn't work with SDK30 as a result of a permissions issue. Would be great to see a fix!

can't take photo in chrome browser

I cloned this project and then run 'ionic serve'. But an error occurred while taking the photo.

TypeError: Cannot read property 'takePhoto' of undefined
    at CameraPWA.capture (pwa-camera.entry.js:252)
    at CameraPWA.handleShutterClick (pwa-camera.entry.js:316)
    at HTMLDivElement.onClick (pwa-camera.entry.js:358)
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Object.onInvokeTask (core.js:41442)
    at ZoneDelegate.invokeTask (zone-evergreen.js:398)
    at Zone.runTask (zone-evergreen.js:167)
    at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:480)
    at invokeTask (zone-evergreen.js:1621)
    at HTMLDivElement.globalZoneAwareCallback (zone-evergreen.js:1647)

Why use platform.ready() ?

Hello!

I have a question about init app, in the article about capacitor 1.0 saw:

Screen Shot 2020-02-02 at 7 01 00 PM

But in your code use:

initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      
      SplashScreen.hide();
    });
  }

What is the reason? I understand if I use Cordova I must use platform.ready but with Capacitor, it's not necessary.

Update jasmine-core

When running the command ionic start photo-gallery tabs --type=angular --capacitor from the tutorial, the package.json in the photo-gallery folder has jasmine-core at 3.4, which gives an npm warning because 3.5 is needed. Updating that number to 3.5 mitigates the warning.

Urgent :First time First Ionic Angular app not running try so much options ...

ng.cmd run app:serve --host=localhost --port=8100 [ng] An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json' [ng] Require stack: [ng] - C:\Users\hp\photo-gallery\node_modules@angular-devkit\architect\node\node-modules-architect-host.js [ng] - C:\Users\hp\photo-gallery\node_modules@angular-devkit\architect\node\index.js [ng] - C:\Users\hp\photo-gallery\node_modules@angular\cli\models\architect-command.js [ng] - C:\Users\hp\photo-gallery\node_modules@angular\cli\commands\run-impl.js [ng] - C:\Users\hp\photo-gallery\node_modules@angular-devkit\schematics\tools\export-ref.js [ng] - C:\Users\hp\photo-gallery\node_modules@angular-devkit\schematics\tools\index.js [ng] - C:\Users\hp\photo-gallery\node_modules@angular\cli\utilities\json-schema.js [ng] - C:\Users\hp\photo-gallery\node_modules@angular\cli\models\command-runner.js [ng] - C:\Users\hp\photo-gallery\node_modules@angular\cli\lib\cli\index.js [ng] - C:\Users\hp\photo-gallery\node_modules@angular\cli\lib\init.js [ng] - C:\Users\hp\photo-gallery\node_modules@angular\cli\bin\ng [ng] See "C:\Users\hp\AppData\Local\Temp\ng-48spjQ\angular-errors.log" for further details. [ERROR] ng has unexpectedly closed (exit code 127). The Ionic CLI will exit. Please check any output above for error details.
ionic error

Fail to npm install

Fail to npm install and got error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @ionic/[email protected]
npm ERR! Found: @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"^12.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular-devkit/build-angular@"^0.1102.4" from @ionic/[email protected]
npm ERR! node_modules/@ionic/angular-toolkit
npm ERR! dev @ionic/angular-toolkit@"^3.1.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! peer @angular-devkit/build-angular@"^0.1102.4" from @ionic/[email protected]
npm ERR! node_modules/@ionic/angular-toolkit
npm ERR! dev @ionic/angular-toolkit@"^3.1.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Error in electron

I try add electron with this steps:

  1. ionic build --prod
  2. ionic cap add electron
  3. ionic cap copy
  4. ionic cap open electron

And show this error:

Screen Shot 2020-02-02 at 7 35 37 PM

Unable to access camera on mobile when running app through browser

Hi, I've been following your tutorial for this app and I've managed to get it to run just fine on desktop Chrome using ionic serve. I've also tried running them within web browsers on both android and iOS devices but the camera doesn't launch on mobile - nothing happens when you click on the camera button. Will it only work on mobile if deployed and run as mobile apps? Or am I missing something here?

Thanks!

Missing steps in the tutorial

You are using lazy loading for modules. So you have to configure and create the files apps/app-routing.module.ts and
tabs-routing.module.ts . I believe this documentation is missing in your tutorial, and the first page, "Taking Photos" is not working.

bug:

Prerequisites

Ionic Framework Version

v5.x, v6.x, v7.x

Current Behavior

The my-first-app angular sample app unit tests fail.

ionic start ionic-my-first-app my-first-app --type=angular

cd ionic-my-first-app

npm run test

yields:

$ npm run test

> [email protected] test
> ng test

⠋ Generating browser application bundles (phase: setup)...Compiling @angular/core : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/core/testing : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
Compiling @angular/platform-browser/testing : es2015 as esm2015
Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling @ionic/angular : es2015 as esm2015
⠙ Generating browser application bundles (phase: building)...10 10 2023 16:36:36.811:WARN [karma]: No captured browser, open http://localhost:9876/
10 10 2023 16:36:36.822:INFO [karma-server]: Karma v6.3.20 server started at http://localhost:9876/
10 10 2023 16:36:36.823:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
10 10 2023 16:36:36.825:INFO [launcher]: Starting browser Chrome
✔ Browser application bundle generation complete.

./src/app/app.component.spec.ts:5:0-63 - Error: Module not found: Error: Can't resolve '@ionic-native/splash-screen/ngx' in '/usr/local/YML/WWW/miles-by-motorcycle.com/ionic-my-first-app/src/app'

./src/app/app.component.spec.ts:6:0-57 - Error: Module not found: Error: Can't resolve '@ionic-native/status-bar/ngx' in '/usr/local/YML/WWW/miles-by-motorcycle.com/ionic-my-first-app/src/app'

Error: src/app/app.component.spec.ts:5:30 - error TS2307: Cannot find module '@ionic-native/splash-screen/ngx' or its corresponding type declarations.

5 import { SplashScreen } from '@ionic-native/splash-screen/ngx';
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Error: src/app/app.component.spec.ts:6:27 - error TS2307: Cannot find module '@ionic-native/status-bar/ngx' or its corresponding type declarations.

6 import { StatusBar } from '@ionic-native/status-bar/ngx';
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



✔ Browser application bundle generation complete.

./src/app/app.component.spec.ts:5:0-63 - Error: Module not found: Error: Can't resolve '@ionic-native/splash-screen/ngx' in '/usr/local/YML/WWW/miles-by-motorcycle.com/ionic-my-first-app/src/app'

./src/app/app.component.spec.ts:6:0-57 - Error: Module not found: Error: Can't resolve '@ionic-native/status-bar/ngx' in '/usr/local/YML/WWW/miles-by-motorcycle.com/ionic-my-first-app/src/app'

Error: src/app/app.component.spec.ts:5:30 - error TS2307: Cannot find module '@ionic-native/splash-screen/ngx' or its corresponding type declarations.

5 import { SplashScreen } from '@ionic-native/splash-screen/ngx';
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Error: src/app/app.component.spec.ts:6:27 - error TS2307: Cannot find module '@ionic-native/status-bar/ngx' or its corresponding type declarations.

6 import { StatusBar } from '@ionic-native/status-bar/ngx';
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expected Behavior

It should pass the unit tests.

Steps to Reproduce

$ ionic start ionic-my-first-app my-first-app --type=angular

$ cd ionic-my-first-app

$ npm run test

Code Reproduction URL

No response

Ionic Info

Ionic:

Ionic CLI : 7.1.1 (/home/yml/.config/nvm/versions/node/v16.14.2/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.9.4
@angular-devkit/build-angular : 12.2.18
@angular-devkit/schematics : 12.2.18
@angular/cli : 12.2.18
@ionic/angular-toolkit : 4.0.0

Capacitor:

Capacitor CLI : 4.4.0
@capacitor/android : 4.4.0
@capacitor/core : 4.4.0
@capacitor/ios : 4.4.0

Utility:

cordova-res : not installed globally
native-run (update available: 1.7.3) : 1.7.1

System:

NodeJS : v16.14.2 (/home/yml/.config/nvm/versions/node/v16.14.2/bin/node)
npm : 8.5.0
OS : Linux 5.3

Additional Information

The spec references ionic-native and not capacitor.

Upgrade to latest Angular and Ionic framework

This projekt is currenly at Angular 12 (!) while the latest Angular version is 18. Also Ionic itself it at version 8 now nad this project is still using version 5.

If this project should reflect the outcome after going through the tutorial at https://ionicframework.com/docs/angular/your-first-app then this repository should be kept up to date with the latest package versions. It should also use the latest features (e.g. standalone components, signals, zoneless) from Angular and the latest syntax.

If this project is kept updated it can serve both as a test project when working with the ecosystem (like testing Android/IOS builds etc.) and as a validation project to check when running into issues with the tutorial.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.