Solved

Routing based on dropdown change in angularjs

Posted on 2014-11-08
1
522 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

803 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