@@ -3,52 +3,51 @@ import { NavController, AlertController } from 'ionic-angular';
3
3
import { BarcodeScanner } from 'ionic-native' ;
4
4
5
5
@Component ( {
6
- selector : 'page-barcodescanner' ,
7
- templateUrl : 'barcodescanner.html'
6
+ selector : 'page-barcodescanner' ,
7
+ templateUrl : 'barcodescanner.html'
8
8
} )
9
9
export class BarcodescannerPage {
10
10
11
- public barcodeData ;
12
-
13
- constructor ( public navCtrl : NavController , public alertCtrl : AlertController ) { }
14
-
15
- ionViewDidLoad ( ) {
16
- console . log ( 'ionViewDidLoad BarcodescannerPage' ) ;
17
- }
18
-
19
- scan ( ) {
20
-
21
- let opciones =
22
- {
23
- preferFrontCamera : false , // iOS and Android
24
- showFlipCameraButton : true , // iOS and Android
25
- showTorchButton : true , // iOS and Android
26
- torchOn : false , // Android, launch with the torch switched on (if available)
27
- prompt : "Place a barcode inside the scan area" , // Android
28
- resultDisplayDuration : 500 , // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
29
- formats : "QR_CODE,PDF_417" , // default: all but PDF_417 and RSS_EXPANDED
30
- orientation : "portrait" , // Android only (portrait|landscape), default unset so it rotates with the device
31
- disableAnimations : true , // iOS
32
- disableSuccessBeep : false // iOS
33
- } ;
34
-
35
- BarcodeScanner . scan ( opciones )
36
- . then ( ( data ) => {
37
- this . barcodeData = data ;
38
- let alert = this . alertCtrl . create ( {
39
- title : 'Scan Results' ,
40
- subTitle : data . text ,
41
- buttons : [ 'OK' ]
42
- } ) ;
43
- alert . present ( ) ;
44
- } ) . catch ( ( err ) => {
45
- let alert = this . alertCtrl . create ( {
46
- title : 'Attention!' ,
47
- subTitle : err ,
48
- buttons : [ 'Close' ]
49
- } ) ;
50
- alert . present ( ) ;
51
- } ) ;
52
- }
53
-
11
+ public barcodeData ;
12
+
13
+ constructor ( public navCtrl : NavController , public alertCtrl : AlertController ) { }
14
+
15
+ ionViewDidLoad ( ) {
16
+ console . log ( 'ionViewDidLoad BarcodescannerPage' ) ;
17
+ }
18
+
19
+ scan ( ) {
20
+
21
+ let options =
22
+ {
23
+ preferFrontCamera : false , // iOS and Android
24
+ showFlipCameraButton : true , // iOS and Android
25
+ showTorchButton : true , // iOS and Android
26
+ torchOn : false , // Android, launch with the torch switched on (if available)
27
+ prompt : "Place a barcode inside the scan area" , // Android
28
+ resultDisplayDuration : 500 , // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
29
+ formats : "QR_CODE,PDF_417" , // default: all but PDF_417 and RSS_EXPANDED
30
+ orientation : "portrait" , // Android only (portrait|landscape), default unset so it rotates with the device
31
+ disableAnimations : true , // iOS
32
+ disableSuccessBeep : false // iOS
33
+ } ;
34
+
35
+ BarcodeScanner . scan ( options )
36
+ . then ( ( data ) => {
37
+ this . barcodeData = data ;
38
+ let alert = this . alertCtrl . create ( {
39
+ title : 'Scan Results' ,
40
+ subTitle : data . text ,
41
+ buttons : [ 'OK' ]
42
+ } ) ;
43
+ alert . present ( ) ;
44
+ } ) . catch ( ( err ) => {
45
+ let alert = this . alertCtrl . create ( {
46
+ title : 'Attention!' ,
47
+ subTitle : err ,
48
+ buttons : [ 'Close' ]
49
+ } ) ;
50
+ alert . present ( ) ;
51
+ } ) ;
52
+ }
54
53
}
0 commit comments