To see this in action, checkout the example project here.
$ ionic cordova plugin add cordova-plugin-file
$ ionic cordova plugin add cordova-plugin-photos
Since Android plugin implementation is written on Java 7, you have to switch your project to Java 7 or 8. https://github.com/domax/cordova-plugin-photos
If your project is Gradle-driven, just open your project's
platform > android > build.gradle
script and replace JavaVersion.VERSION_1_6 to JavaVersion.VERSION_1_7, like that:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
$ npm i --save cs-photo-gallery
Import CsPhotoGalleryModule.forRoot()
in your app main module
import { CsPhotoGalleryModule } from 'cs-photo-gallery';
@NgModule({
...
imports: [
...
CsPhotoGalleryModule.forRoot()
],
...
})
export class AppModule {}
openCsPhotoGallery(options?: ICsOptionsGallery): Observable<any>
(optional) Advanced configuration.
Param | Type | Description | Default |
---|---|---|---|
maxFiles |
number | Maximum number of selectable files. | 30 |
{
nativeURLs: [...]
}
Array of nativeURLs (String)
import { Component } from '@angular/core';
import { CsPhotoGalleryController } from 'cs-photo-gallery';
@Component({
selector: 'test-page',
templateUrl: './test.html'
})
export class TestPage {
constructor(
private _csPhotoGalleryCtrl: CsPhotoGalleryController
) {}
openFileChooser() {
this._csPhotoGalleryCtrl.openCsPhotoGallery()
.subscribe(data => {
console.log(data);
});
}
}
import { Component } from '@angular/core';
import { CsPhotoGalleryController } from 'cs-photo-gallery';
@Component({
selector: 'test-page',
templateUrl: './test.html'
})
export class TestPage {
constructor(
private _csPhotoGalleryCtrl: CsPhotoGalleryController
) {}
openFileChooser() {
let options = {
maxFiles: 10
};
this._csPhotoGalleryCtrl.openCsPhotoGallery(options)
.subscribe(data => {
console.log(data);
});
}
}
- Having an issue? or looking for support? Open an issue and we will get you the help you need.
- Got a new feature or a bug fix? Fork the repo, make your changes, and submit a pull request.
If you find this project useful, please star the repo to let people know that it's reliable. Also, share it with friends and colleagues that might find this useful as well. Thank you 😄