Group page.html
My Groups
{{ item.groupName }}
Groups.page.ts
import { Component, OnInit } from ‘@angular/core’;
import { NavController, Events, LoadingController } from ‘@ionic/angular’;
import { GroupsService } from ‘…/services/groups.service’;
import { Router, ActivatedRoute } from ‘@angular/router’;
@Component({
selector: ‘app-groups’,
templateUrl: ‘./groups.page.html’,
styleUrls: [’./groups.page.scss’],
})
export class GroupsPage implements OnInit {
allmygroups:any;
constructor(private route:Router,private router:ActivatedRoute,private grpService:GroupsService,private loadingCtrl:LoadingController,private navCtrl:NavController,private events:Events) { }
ngOnInit() {
}
openchat(group) {
this.grpService.getintogroup(group.groupName);
//this.navCtrl.navigateRoot(‘groupchat’,group.groupName);
let groupName = group.groupName;
this.route.navigate([‘groupchat’,groupName]);
}
}
groupchat.page.ts
import { Component, OnInit, Inject, ViewChild } from ‘@angular/core’;
import { ActionSheetController, NavController } from ‘@ionic/angular’;
import { GroupsService } from ‘…/services/groups.service’;
import { Router, ActivatedRoute, } from ‘@angular/router’;
@Component({
selector: ‘app-groupchat’,
templateUrl: ‘./groupchat.page.html’,
styleUrls: [’./groupchat.page.scss’],
})
export class GroupchatPage implements OnInit {
owner: boolean = false;
groupName:any = ;
constructor(private route:Router,private router:ActivatedRoute,private navCtrl:NavController,private actionSheet:ActionSheetController,private grpService:GroupsService) {
//this.groupName = this.navParams.get(‘groupName’);
this.groupName = this.router.snapshot.paramMap.get(‘groupName’);
this.grpService.getownership(this.groupName).then((res) => {
if(res)
this.owner = true;
}).catch((err) => {
alert(err);
})
}
app.routing,module.ts
import { NgModule } from ‘@angular/core’;
import { PreloadAllModules, RouterModule, Routes,Router } from ‘@angular/router’;
const routes: Routes = [
{ path: ‘’, redirectTo: ‘login’, pathMatch: ‘full’ },
{ path: ‘login’, loadChildren: ‘./login/login.module#LoginPageModule’ },
{ path: ‘tabs’, loadChildren: ‘./tabs/tabs.module#TabsPageModule’ },
{ path: ‘chats’, loadChildren: ‘./chats/chats.module#ChatsPageModule’ },
{ path: ‘groups’, loadChildren: ‘./groups/groups.module#GroupsPageModule’ },
{ path: ‘profile’, loadChildren: ‘./profile/profile.module#ProfilePageModule’ },
{ path: ‘buddies’, loadChildren: ‘./buddies/buddies.module#BuddiesPageModule’ },
{ path: ‘buddychat’, loadChildren: ‘./buddychat/buddychat.module#BuddychatPageModule’ },
{ path: ‘passwordreset’, loadChildren: ‘./passwordreset/passwordreset.module#PasswordresetPageModule’ },
{ path: ‘profilepic’, loadChildren: ‘./profilepic/profilepic.module#ProfilepicPageModule’ },
{ path: ‘signup’, loadChildren: ‘./signup/signup.module#SignupPageModule’ },
{ path: ‘newgroup’, loadChildren: ‘./newgroup/newgroup.module#NewgroupPageModule’ },
{ path: ‘groupchat/groupName’, loadChildren: ‘./groupchat/groupchat.module#GroupchatPageModule’ },
{ path: ‘groupbuddies’, loadChildren: ‘./groupbuddies/groupbuddies.module#GroupbuddiesPageModule’ },
{ path: ‘groupmembers’, loadChildren: ‘./groupmembers/groupmembers.module#GroupmembersPageModule’ },
{ path: ‘groupinfo’, loadChildren: ‘./groupinfo/groupinfo.module#GroupinfoPageModule’ },
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule { }
This is my code I have an error while routing to groupchat page from group page by using this code openchat(group) {
** this.grpService.getintogroup(group.groupName);**
** //this.navCtrl.navigateRoot(‘groupchat’,group.groupName);**
** let groupName = group.groupName;**
** this.route.navigate([‘groupchat’,groupName]);**
** }**
THIS IS MY ERROR PLEASE HELP ME OUT
core.js:15724 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: ‘groupchat/Mortal%20Kombat’
Error: Cannot match any routes. URL Segment: ‘groupchat/Mortal%20Kombat’
at ApplyRedirects.push…/node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:2469)
at CatchSubscriber.selector (router.js:2450)
at CatchSubscriber.push…/node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:34)
at MapSubscriber.push…/node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:79)
at MapSubscriber.push…/node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:59)
at MapSubscriber.push…/node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:79)
at MapSubscriber.push…/node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:59)
at MapSubscriber.push…/node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:79)
at MapSubscriber.push…/node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:59)
at ThrowIfEmptySubscriber.push…/node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:79)
at resolvePromise (zone.js:831)
at resolvePromise (zone.js:788)
at zone.js:892
at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17290)
at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push…/node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)
at ZoneTask.push…/node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:502)
at invokeTask (zone.js:1744)