質問編集履歴

1

usersComponentを足しました!

2016/12/16 13:36

投稿

KoheiOkazaki
KoheiOkazaki

スコア43

test CHANGED
File without changes
test CHANGED
@@ -135,3 +135,199 @@
135
135
 
136
136
 
137
137
  そもそもDIを使うのがベストプラクティスなのかもわかっていないので、そちらも含めてどうするか教えていただけたらとっても嬉しいです。
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+ ```ここに言語を入力
148
+
149
+ @Component({
150
+
151
+ selector: 'ons-page',
152
+
153
+ template: `
154
+
155
+ //テンプレートが入ります。
156
+
157
+ `,
158
+
159
+ styles: [require('./css/template.css')]
160
+
161
+ })
162
+
163
+ export class UsersComponent {
164
+
165
+ private _dialog: any;
166
+
167
+ private _destroyDialog: Function;
168
+
169
+ defaultDateTime: Date;
170
+
171
+ defaultPlusDateTime: Date;
172
+
173
+ requestId: any;
174
+
175
+ requests: FirebaseListObservable<any[]>;
176
+
177
+ therapistId: any;
178
+
179
+ therapistObject: any;
180
+
181
+ therapistGender: string;
182
+
183
+ hoge: any;
184
+
185
+ requestContentArray: any[];
186
+
187
+ jage: Array<any[]>;
188
+
189
+ userImageUrl: string
190
+
191
+ genderSubject: Subject<any>;
192
+
193
+ startingTime: any;
194
+
195
+ endTime: any;
196
+
197
+
198
+
199
+ constructor(
200
+
201
+ private _navigator: OnsNavigator,
202
+
203
+ private _params: Params,
204
+
205
+ private _af: AngularFire,
206
+
207
+ private _us: UserService,
208
+
209
+ private _rs: RequestService,
210
+
211
+ private _ds: DomSanitizer,
212
+
213
+ private _df: DialogFactory
214
+
215
+ ){
216
+
217
+ this.therapistId = this._params.data['therapistId'];
218
+
219
+ console.log(this.therapistId);
220
+
221
+ this.getTherapistInfo(this.therapistId);
222
+
223
+ this.requests = this._af.database.list('/requests');
224
+
225
+ this.getCurrentLocalDateTime()
226
+
227
+ }
228
+
229
+ say(): string {
230
+
231
+ return "foo";
232
+
233
+ }
234
+
235
+
236
+
237
+ ngAfterViewInit() {
238
+
239
+ this._df
240
+
241
+ .createDialog(MyDialogComponent, {message: 'This is just an example.'})
242
+
243
+ .then(({dialog, destroy}) => {
244
+
245
+ this._dialog = dialog;
246
+
247
+ this._destroyDialog = destroy;
248
+
249
+ });
250
+
251
+ }
252
+
253
+
254
+
255
+ showDialog() {
256
+
257
+ console.log("きたよ");
258
+
259
+ if (this._dialog) {
260
+
261
+ this._dialog.show();
262
+
263
+ }
264
+
265
+ }
266
+
267
+ getTherapistInfo(therapistId: any) {
268
+
269
+ this.therapistObject = this._af.database.object('/therapists/' + therapistId);
270
+
271
+ this.therapistObject.subscribe(response => {
272
+
273
+ this.therapistGender = response['gender'];
274
+
275
+ });
276
+
277
+ }
278
+
279
+ getCurrentLocalDateTime() {
280
+
281
+ this.defaultDateTime = new Date(Date.now());
282
+
283
+ this.defaultDateTime.setUTCHours(this.defaultDateTime.getUTCHours() + 9);
284
+
285
+ this.defaultPlusDateTime = new Date(Date.now());
286
+
287
+ this.defaultPlusDateTime.setUTCHours(this.defaultPlusDateTime.getUTCHours() + 10);
288
+
289
+ this.defaultDateTime.setSeconds(0,0);
290
+
291
+ this.defaultPlusDateTime.setSeconds(0,0);
292
+
293
+ this.startingTime = this.getISOStringWithoutSecsAndMillisecs1(this.defaultDateTime.toISOString().split('T'));
294
+
295
+ this.endTime = this.getISOStringWithoutSecsAndMillisecs1(this.defaultPlusDateTime.toISOString().split('T'));
296
+
297
+ }
298
+
299
+ getISOStringWithoutSecsAndMillisecs1(dateAndTime) {
300
+
301
+ const time = dateAndTime[1].split(':')
302
+
303
+ return dateAndTime[0]+' '+time[0]+':'+time[1]
304
+
305
+ }
306
+
307
+ getUserProfileImageUrl(request: any) {
308
+
309
+ let id: string = request.userId;
310
+
311
+ return "https://firebasestorage.googleapis.com/v0/b/relappi-5ca22.appspot.com/o/images%2Fusers%2F" + id + "_users.jpg" + "?alt=media&token=f97839fa-804a-4497-81ac-44ecc4ef64cc"
312
+
313
+ }
314
+
315
+ pushToDetail(request: any){
316
+
317
+ this._navigator.element.pushPage(UserDetailComponent, {
318
+
319
+ data: {
320
+
321
+ therapistId: this.therapistId,
322
+
323
+ request: request,
324
+
325
+ }
326
+
327
+ });
328
+
329
+ }
330
+
331
+ }
332
+
333
+ ```