Take out all special characters in string

This commit is contained in:
tiago.kayaya
2021-12-10 11:41:24 +01:00
parent e5edac65af
commit d7300080c3
3 changed files with 37 additions and 42 deletions
@@ -1,5 +1,6 @@
import { analyzeAndValidateNgModules } from '@angular/compiler';
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { NavigationStart, Router } from '@angular/router';
import { ModalController, NavParams, PickerController, PopoverController } from '@ionic/angular';
import { ChatService } from 'src/app/services/chat.service';
import { DataService } from 'src/app/services/data.service';
@@ -35,22 +36,29 @@ export class NewGroupPage implements OnInit{
private chatService: ChatService,
private dataService:DataService,
private processesService: ProcessesService,
private router: Router,
)
{
this.isGroupCreated = false;
//this.groupName = this.navParams.get('name');
alert('New group '+this.dataService.get("newGroup"))
}
ngOnInit() {
//alert(this.dataService.get("newGroup"))
setTimeout(() => {
//alert(this.dataService.get("newGroup"))
}, 100)
if(this.dataService.get("newGroup") == true){
this.task = this.dataService.get("task");
this.groupName = this.task.Folio;
this.documents = this.dataService.get("documents");
}
this.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
alert('New group '+this.dataService.get("newGroup"))
if (this.dataService.get("newGroup")) {
this.task = this.dataService.get("task");
this.groupName = this.task.Folio;
this.documents = this.dataService.get("documents");
}
}
else{
this.dataService.set("newGroup", false);
}
});
console.log(this.task);
}
@@ -82,6 +90,8 @@ export class NewGroupPage implements OnInit{
createGroup(){
let name = this.groupName.split(' ').join('-');
//Take out all special characters in string
name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
let body = { "name":name, }
this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');