How do I navigate from one component to other in the same parent class using UI router in Angular 6?


Angular UI-Router Visualizer


import { Component, OnInit, ChangeDetectorRef, EventEmitter, Output, Input } from '@angular/core';
import { AppService } from '@app/shared/app.service';
import { Schema } from '@app/shared/model/app.modal';
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { StateService } from '@uirouter/core';

  selector: 'app-design-app',
  templateUrl: './design-app.component.html',
  styleUrls: ['./design-app.component.scss']
export class DesignAppComponent implements OnInit {
  schema: Schema=new Schema(); 
  fields: object[] = this.appService.fields;
  mobileQuery: MediaQueryList;
  isScrolled: boolean;
  constructor(private appService: AppService, private $state: StateService) {

  sideNavScrollControl() {
    window.onscroll = () => {
      if (document.body.scrollTop > 140 || document.documentElement.scrollTop > 140) {
        this.isScrolled = true;
      } else {
        this.isScrolled = false;


  ngOnInit() {



<!-- Preview, workflow and more actions button starts -->
<div class="preview-workflow-btn">
    <button mat-raised-button type="button" class="more-actions-btn" [matMenuTriggerFor]="menu">More Actions<i class="fa fa-sort-down dropdown-icon"></i></button>
    <mat-menu #menu="matMenu">
      <button mat-menu-item>Basic Details</button>
      <button mat-menu-item>Settings</button>
      <button mat-menu-item>Acceptance</button>
  <button mat-raised-button type="button" class="workflow-btn">Workflow</button>
  <button mat-raised-button type="button" class="preview-btn" (click)="previewPublish">Preview</button>
<!-- Preview, workflow and more actions button ends -->

<div class="draggable-block-section" fxFlex="100" fxLayout="column">

<!-- Left form fields panel starts -->
  <div class="left-panel" fxFlex="50">
    <app-draggable [config]="fields"></app-draggable>
<!-- Left form fields panel ends -->

<!-- Right panel starts -->
  <div class="right-panel" fxFlex="50">
    <app-blocks [config]="schema"></app-blocks>
<!-- Right panel ends -->


Question: Now how do I redirect to preview-publish -> horizontal on clicking the ‘Preview button’ mentioned in the above html file. Please help out. The click functionality is not working. on going to publish-preview by default ‘horizontal’ should be viewed.


<button mat-raised-button type="button" uiSref="preview-publish">Preview</button>

And in its routing by default we will redirect to horizontal as shown below:

states: [
      parent: "app-builder",
      name: "preview-publish",
      redirectTo: "horizontal",
      url: "/preview-publish",
      component: PreviewPublishComponent
      parent: "preview-publish",
      name: "horizontal",
      url: "/horizontal",
      component: HorizontalComponent
      parent: "preview-publish",
      name: "vertical",
      url: "/vertical",
      component: VerticalComponent


Answered By – Palak Halvadia

Answer Checked By – Clifford M. (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.