forms - Paths/links with unique ID's angular2 -
i'm creating quiz making/sharing website using angular2 not sure how share quizzes. thinking of using each of quizzes identifiers urls. quizzes made using forms , saved on docmentdb json. have unique id's identify them. ideas how this?
those urls must dynamically created, new quizzes can submitted , thereafter accessed.
you can use same base url page quiz, differentiate quizzes path parameter like:
quizsite.com/#/quiz/12 (12 being quiz id)
inside component can read path parameters located in url , values accessing activateroute object:
component
import { component } '@angular/core'; import { activatedroute } '@angular/router'; @component({ templateurl: 'quizcomponent.html', }) export class quizcomponent { constructor(private activatedroute: activatedroute){} ngoninit() { // reason being observable can watch parameter changing (manually in url, or programmatically) , without page refresh, read new parameter , change quiz this.activatedroute.params.subscribe(params => { console.log(params.quizid); // parameter can make call rest api , return data quiz }); } }
Comments
Post a Comment