File tree Expand file tree Collapse file tree 4 files changed +39
-47
lines changed Expand file tree Collapse file tree 4 files changed +39
-47
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { SplashScreen } from '@ionic-native/splash-screen';
1010export class MyApp {
1111 @ViewChild ( Nav ) nav : Nav ;
1212
13- rootPage = 'TopicsPage ' ;
13+ rootPage = 'topics ' ;
1414
1515 pages : Array < { title : string , component : any } > ;
1616
@@ -27,14 +27,6 @@ export class MyApp {
2727 }
2828
2929 ngAfterViewInit ( ) {
30- console . log ( 'ng after view init' )
31- //Deeplinks.routeWithNavController(this.nav, {
32- // '/topics': TopicsPage,
33- // '/user/:loginname': UserPage
34- //}).subscribe((match) => {
35- // console.log('Successfully routed', match);
36- //}, (nomatch) => {
37- // console.warn('Unmatched Route', nomatch);
38- //});
30+ console . log ( 'ng after view init' )
3931 }
4032}
Original file line number Diff line number Diff line change 1515
1616< ion-content padding >
1717 < div class ="topic-info " *ngIf ="topic ">
18- < div class ="row topic ">
18+ < div class ="row topic ">
1919 < div class ="col col90 ">
2020 < h4 class ="title "> {{topic.title}}</ h4 >
2121 < div class ="summary ">
2222 < strong >
23- < a (click) =" gotoUser( topic.author.loginname) ">
23+ < a href =" #user/{{ topic.author.loginname}} ">
2424 < img [src] ="topic.author.avatar_url " class ="avatar ">
2525 {{topic.author.loginname}}</ a >
2626 </ strong >
@@ -31,17 +31,17 @@ <h4 class="title">{{topic.title}}</h4>
3131 </ div >
3232 </ div >
3333
34- < ion-list class ="replies ">
35- < ion-item *ngFor ="let reply of topic.replies ">
36- {{reply.author.loginname}}
37- < div class ="reply-content " [innerHTML] ="reply.content "> </ div >
38- < span class ="item-note cnode " *ngIf ="reply.ups.length > 0 ">
39- < i class ="icon ion-thumbsup "> </ i >
40- {{reply.ups.length}}
41-
42- </ span >
43- </ ion-item >
44- </ ion-list >
34+ < ion-list class ="replies ">
35+ < ion-item *ngFor ="let reply of topic.replies ">
36+ {{reply.author.loginname}}
37+ < div class ="reply-content " [innerHTML] ="reply.content "> </ div >
38+ < span class ="item-note cnode " *ngIf ="reply.ups.length > 0 ">
39+ < i class ="icon ion-thumbsup "> </ i >
40+ {{reply.ups.length}}
41+
42+ </ span >
43+ </ ion-item >
44+ </ ion-list >
4545 </ div >
4646
4747</ ion-content >
Original file line number Diff line number Diff line change 11import { Component } from '@angular/core' ;
22import { NavController , NavParams , IonicPage } from 'ionic-angular' ;
33
4- import { UserPage } from '../user/user' ;
54import { Topic } from '../topics/topic' ;
65import { TopicService } from '../../providers/topic-service' ;
76/*
@@ -11,12 +10,12 @@ import { TopicService } from '../../providers/topic-service';
1110 Ionic pages and navigation.
1211*/
1312@IonicPage ( {
14- name : 'topic'
13+ name : 'topic'
1514} )
1615@Component ( {
1716 selector : 'page-topic' ,
1817 templateUrl : 'topic.html' ,
19- providers : [ TopicService ]
18+ providers : [ TopicService ]
2019} )
2120export class TopicPage {
2221
@@ -29,21 +28,21 @@ export class TopicPage {
2928 console . log ( 'ionViewDidLoad TopicPage' ) ;
3029 }
3130
32- ngOnInit ( ) : void {
33- this . getTopic ( )
34- }
31+ ngOnInit ( ) : void {
32+ this . getTopic ( )
33+ }
3534
36- getTopic ( ) : void {
37- this . topicService . getTopicById ( this . navParams . get ( 'id' ) ) . then (
38- ( topic ) => {
35+ getTopic ( ) : void {
36+ this . topicService . getTopicById ( this . navParams . get ( 'id' ) ) . then (
37+ ( topic ) => {
3938 this . topic = topic
4039 console . log ( this . topic )
4140 }
42- ) ;
43- }
41+ ) ;
42+ }
4443
4544 gotoUser ( loginName : String ) : void {
4645 console . log ( 'goto user' , loginName ) ;
47- this . navCtrl . push ( 'user' , { loginName : loginName } )
46+ this . navCtrl . push ( 'user' , { loginName : loginName } )
4847 }
4948}
Original file line number Diff line number Diff line change @@ -10,35 +10,36 @@ import { UserService } from '../../providers/user-service';
1010 Ionic pages and navigation.
1111*/
1212@IonicPage ( {
13- name : 'user'
13+ name : 'user' ,
14+ segment : 'user/:loginName'
1415} )
1516@Component ( {
1617 selector : 'page-user' ,
1718 templateUrl : 'user.html' ,
18- providers : [ UserService ]
19+ providers : [ UserService ]
1920} )
2021export class UserPage {
2122
22- user : User
23+ user : User
2324
2425 constructor ( public navCtrl : NavController , public navParams : NavParams , private userService : UserService ) {
25- }
26+ }
2627
2728 ionViewDidLoad ( ) {
2829 console . log ( 'ionViewDidLoad UserPage' ) ;
2930 }
3031
31- ngOnInit ( ) : void {
32- this . getUser ( )
33- }
32+ ngOnInit ( ) : void {
33+ this . getUser ( )
34+ }
3435
35- getUser ( ) : void {
36- this . userService . getByLoginName ( this . navParams . get ( 'loginName' ) ) . then (
37- ( user ) => {
36+ getUser ( ) : void {
37+ this . userService . getByLoginName ( this . navParams . get ( 'loginName' ) ) . then (
38+ ( user ) => {
3839 this . user = user
3940 console . log ( this . user )
4041 }
41- ) ;
42- }
42+ ) ;
43+ }
4344
4445}
You can’t perform that action at this time.
0 commit comments