Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

angular refresh page without reloading

this.router.navigate(['path/to'])
  .then(() => {
    window.location.reload();
  });
Comment

refresh page angular

refresh(): void {
    window.location.reload();
}
Comment

How to Reload a Component in Angular

reloadComponent() {
  let currentUrl = this.router.url;
      this.router.routeReuseStrategy.shouldReuseRoute = () => false;
      this.router.onSameUrlNavigation = 'reload';
      this.router.navigate([currentUrl]);
  }
Comment

refresh current component angular

  reloadCurrentRoute() {
    let currentUrl = this._router.url;
    this._router.navigateByUrl('/', {skipLocationChange: true}).then(() => {
        this._router.navigate([currentUrl]);
        console.log(currentUrl);
    });
  }
Comment

angular reload component

reloadCurrentRoute() {
    let currentUrl = this.router.url;
    this.router.navigateByUrl('/', {skipLocationChange: true}).then(() => {
        this.router.navigate([currentUrl]);
    });
}
Comment

reload sub component angular

this.router.navigateByUrl('/RefreshComponent', { skipLocationChange: true }).then(() => {
    this.router.navigate(['Your actualComponent']);
}); 
Comment

refresh angular

@Component({
	selector: 'app-root',
	templateUrl: './app.component.html',
	styleUrls: ['./app.component.css']
})
export class AppComponent {
	title = 'refreshPage';
	constructor(public _router: Router, public _location: Location) { }
	refresh(): void {
		this._router.navigateByUrl("/refresh", { skipLocationChange: true }).then(() => {
		console.log(decodeURI(this._location.path()));
		this._router.navigate([decodeURI(this._location.path())]);
		});
	}
}
Comment

how to make a component reload in angular

DeleteEmployee(id:number)
  {
    this.employeeService.deleteEmployee(id)
    .subscribe( 
      (data) =>{
        console.log(data);
        this.ngOnInit();
      }),
      err => {
        console.log("Error");
      }   
  }
Comment

angular refresh component without reloading page

/*You can use a BehaviorSubject for communicating between different 
components throughout the app. 
You can define a data sharing service containing the BehaviorSubject to 
which you can subscribe and emit changes.

Define a data sharing service
*/

import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';

@Injectable()
export class DataSharingService {
    public isUserLoggedIn: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
}

/*Add the DataSharingService in your AppModule providers entry.

Next, import the DataSharingService in your <app-header> and in the 
component where you perform the sign-in operation. In <app-header> 
subscribe to the changes to isUserLoggedIn subject:
*/

import { DataSharingService } from './data-sharing.service';

export class AppHeaderComponent { 
    // Define a variable to use for showing/hiding the Login button
    isUserLoggedIn: boolean;

    constructor(private dataSharingService: DataSharingService) {

        // Subscribe here, this will automatically update 
        // "isUserLoggedIn" whenever a change to the subject is made.
        this.dataSharingService.isUserLoggedIn.subscribe( value => {
            this.isUserLoggedIn = value;
        });
    }
}

/*In your <app-header> html template, you need to add the *ngIf 
condition e.g.:
*/

<button *ngIf="!isUserLoggedIn">Login</button> 
<button *ngIf="isUserLoggedIn">Sign Out</button>

// Finally, you just need to emit the event once the user has logged in e.g:

someMethodThatPerformsUserLogin() {
    // Some code 
    // .....
    // After the user has logged in, emit the behavior subject changes.
    this.dataSharingService.isUserLoggedIn.next(true);
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: python first n elements of list 
Typescript :: NASDAQ: TSLA 
Typescript :: react tsx component example 
Typescript :: mat dialog disable close 
Typescript :: import on save typescript 
Typescript :: useRef ts 
Typescript :: typescript cannot find name console 
Typescript :: ionic email validation 
Typescript :: typescript key options from array values 
Typescript :: how to run ts file 
Typescript :: how to check if its a character in r 
Typescript :: react-draggable disable 
Typescript :: angular create object 
Typescript :: create a typescript project 
Typescript :: promise.all does not wait 
Typescript :: change textinputlayout color 
Typescript :: python get first n elements of list 
Typescript :: how are uv rays produced 
Typescript :: typescript gitignore 
Typescript :: how to check if var exists python 
Typescript :: typescript usestate array type 
Typescript :: typescript debounce 
Typescript :: ionic scroll to item programmatically 
Typescript :: generic arrow function typescript 
Typescript :: Add correct host key in /Users/ckaburu/.ssh/known_hosts to get rid of this message 
Typescript :: angular typescript filter array group by attribute 
Typescript :: replace multiple elements in a list python 
Typescript :: tonumber typescript / Number typescript 
Typescript :: what are google extensions 
Typescript :: Create Hash Node TypeScript 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =