title: Resolving Multiple Pieces of Data using Resolve Guard in Angular 2
body: <p>I have a PollDetailResolve class that resolves a poll before being navigating to the poll-detail page. However, I also need to resolve a separate piece of data (a boolean that we'll call <code>canVote</code>) that will also make use of PollService.</p>
  
  <p>What is the best way to resolve two or more pieces of data?</p>
  
  <pre><code>@Injectable()
  export class PollDetailResolve implements Resolve&lt;Poll&gt; {
    constructor(private pollService: PollService, private router: Router) { }
  
    resolve(route: ActivatedRouteSnapshot): Observable&lt;Poll&gt; | boolean {
      let id = route.params['id'];
  
      return this.pollService.getById(id)
        .map(poll =&gt; {
          if (poll) {
            return poll;
          } else {
            console.log("NOT FOUND!"); // TODO reroute
          }
        },
        err =&gt; {
          console.error(err);
        });
    }
  }
  </code></pre>
  
  <p>My poll-detail ngOnInit() function:</p>
  
  <pre><code>  ngOnInit(): void {
      this.route.data.forEach((data: { poll: Poll }) =&gt; {
        this.poll = data.poll;
        this.sharePoll(this.poll);
      });
    }
  </code></pre>