Solved

Routing based on dropdown change in angularjs

Posted on 2014-11-08
1
499 Views
Last Modified: 2014-11-12
Hi,

We are developing single page application using angularjs and our index page consists of 3 sections so we have separate pages/partial views  for these sections.My requirement is in the index page we will have dropdown with 3 options and based on option selected I have to show that section(page/html).So in the dropdwon on ng-change there is  a function that will pass selected value to controller and show respective page/view.I am injecting $location service into the controller and showing the respective page/view.But I came to know that using $location service  will redirect to sepearte html/page and will show different url in the address bar of a browser.

I want to show the page/html based on dropdown change without using $location service in the controller, I tried injecting $route into the controller but getting error.Can anyone correct me how to resolve this issue.Here is the plunker routing
0
Comment
Question by:ksd123
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40431732
check the example here at the bottom : https://docs.angularjs.org/api/ng/directive/ngInclude

you may use ng-if too
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now