angular navigate using component
import {Router} from '@angular/router'; // import router from angular router
export class Component{ // Example component..
constructor(private route:Router){}
go(){
this.route.navigate(['/page']); // navigate to other page
}
}//ng new routing-app --routing
//ng generate component first
//ng generate component second
import { Router } from '@angular/router';
...
export class AboutUserComponent implements OnInit {
user: User;
constructor(
private route: ActivatedRoute,
private service: UserService,
private router: Router
) {}
ngOnInit() {
// grab the current username
let username = this.route.snapshot.params['username'];
this.service.getUser(username).then(user => this.user = user);
}
goBack() {
this.router.navigate(['/about']);
}
}
Also in JavaScript:
- document ready without jquery
- click listener on by class name in javascript
- javascript find matching elements in two arrays
- Object destructuring
- javascript foreach object key
- anchor link issue with fixed header css js
- javascript construct new object
- how to split a string in javascript
- node test unit
- js check proccess alive
- const js +=
- go back doesnt load javascript safari
- initialize a map js
- memento database javascript list
- How to make remove buttoon on table using js DOM
- update angular website firebase
- leaflet draw save event
- align left text in reactstrap
- how to check if 2 sprites are touching js
- send message to all servers discord.js
- terser plugin Cannot read property 'javascript' of undefined
- jquery wordpress starter code
- javascript the difference between innerText vs. innerHTML vs. textContent
- javascript list class properties