File tree Expand file tree Collapse file tree 1 file changed +32
-19
lines changed Expand file tree Collapse file tree 1 file changed +32
-19
lines changed Original file line number Diff line number Diff line change 102
102
}
103
103
} ;
104
104
105
- PDFJS . getDocument ( url , null , null , scope . onProgress ) . then (
106
- function ( _pdfDoc ) {
107
- if ( typeof scope . onLoad === 'function' ) {
108
- scope . onLoad ( ) ;
109
- }
110
-
111
- pdfDoc = _pdfDoc ;
112
- scope . renderPage ( scope . pageToDisplay ) ;
113
-
114
- scope . $apply ( function ( ) {
115
- scope . pageCount = _pdfDoc . numPages ;
116
- } ) ;
117
- } , function ( error ) {
118
- if ( error ) {
119
- if ( typeof scope . onError === 'function' ) {
120
- scope . onError ( error ) ;
121
- }
122
- }
105
+ function renderPDF ( ) {
106
+ if ( url && url . length ) {
107
+ PDFJS . getDocument ( url , null , null , scope . onProgress ) . then (
108
+ function ( _pdfDoc ) {
109
+ if ( typeof scope . onLoad === 'function' ) {
110
+ scope . onLoad ( ) ;
111
+ }
112
+
113
+ pdfDoc = _pdfDoc ;
114
+ scope . renderPage ( scope . pageToDisplay ) ;
115
+
116
+ scope . $apply ( function ( ) {
117
+ scope . pageCount = _pdfDoc . numPages ;
118
+ } ) ;
119
+ } , function ( error ) {
120
+ if ( error ) {
121
+ if ( typeof scope . onError === 'function' ) {
122
+ scope . onError ( error ) ;
123
+ }
124
+ }
125
+ }
126
+ ) ;
123
127
}
124
- ) ;
128
+ }
125
129
126
130
scope . $watch ( 'pageNum' , function ( newVal ) {
127
131
scope . pageToDisplay = parseInt ( newVal ) ;
130
134
}
131
135
} ) ;
132
136
137
+ scope . $watch ( 'pdfUrl' , function ( newVal ) {
138
+ if ( newVal !== '' ) {
139
+ console . log ( 'pdfUrl value change detected: ' , scope . pdfUrl ) ;
140
+ url = newVal ;
141
+ scope . pageToDisplay = 1 ;
142
+ renderPDF ( ) ;
143
+ }
144
+ } ) ;
145
+
133
146
}
134
147
} ;
135
148
} ] ) ;
You can’t perform that action at this time.
0 commit comments