Questions tagged [ngroute]

AngularJS module providing routing, deeplinking services and directives for AngularJS apps.

The ngRoute module provides routing, deeplinking services and directives for AngularJS apps.

Resources

878 questions
497
votes
11 answers

Redirecting to a certain route based on condition

I'm writing a small AngularJS app that has a login view and a main view, configured like so: $routeProvider .when('/main' , {templateUrl: 'partials/main.html', controller: MainController}) .when('/login', {templateUrl: 'partials/login.html',…
st.never
  • 11,623
  • 4
  • 18
  • 21
317
votes
10 answers

What's the most concise way to read query parameters in AngularJS?

I'd like to read the values of URL query parameters using AngularJS. I'm accessing the HTML with the following URL: http://127.0.0.1:8080/test.html?target=bob As expected, location.search is "?target=bob". For accessing the value of target, I've…
Ellis Whitehead
  • 6,292
  • 4
  • 16
  • 14
256
votes
14 answers

Removing the fragment identifier from AngularJS urls (# symbol)

Is it possible to remove the # symbol from angular.js URLs? I still want to be able to use the browser's back button, etc, when I change the view and will update the URL with params, but I don't want the # symbol. The tutorial routeProvider is…
Tim Webster
  • 9,018
  • 8
  • 24
  • 30
237
votes
8 answers

AngularJS : How do I switch views from a controller function?

I am trying to use the ng-click feature of AngularJS to switch views. How would I go about doing this with the code below? index.html
click me
The_Brink
  • 2,619
  • 2
  • 13
  • 18
100
votes
5 answers

angularjs 1.6.0 (latest now) routes not working

I was expecting to see this question on Stackoverflow but didn't. Apparently I'm the only one having this problem that seems to me to be very common. I have a basic project I am working on but the routes don't seem to work even though everything…
38
votes
7 answers

AngularJS Paging with $location.path but no ngView reload

My single page application loads a home page and I want to display a series of ideas. Each of the ideas is displayed in an animated flash container, with animations displayed to cycle between the ideas. Ideas are loaded using $http: $scope.flash =…
chrisbateskeegan
  • 953
  • 1
  • 10
  • 13
35
votes
6 answers

Angular 1 - get current URL parameters

I want to extract data from current URL and use it in controller. For example I have this url: app.dev/backend/surveys/2 Bits that I want to extract: app.dev/backend/ :type / :id Is there anything in Angular that could help me with this task ?
sarunast
  • 2,433
  • 3
  • 23
  • 34
30
votes
2 answers

"Controller as" syntax for ng-view

I was wondering how I use the Controller as syntax in combination with ngRoute since I cant do ng-controller="Controller as ctrl"
user1703761
  • 1,055
  • 3
  • 11
  • 22
21
votes
5 answers

How to display common header and footer by default in angular 2?

I have common header components and footer components. countries list are loading on homepage. whenever click on the country. page will get reloaded and displaying text Loading... and then header and footer displaying. but I want to display the…
Vel
  • 8,204
  • 5
  • 26
  • 57
15
votes
1 answer

Angular routes contain #! in the url instead of #

Recently I have noticed that when using ngRoute module in an AngularJS app, the route contains #! in the URL, which was earlier just the #. For example, www.webiste.com/#/login becomes www.website.com/#!/login I have to enable the html5Mode and also…
14
votes
2 answers

Angular app not loading CSS and JS on refreshing page?

I have an app using AngularJS. Here is a link of it - Angular App All the links in the navbar are using default angular router. All the pages work fine when i refresh them, but a page like this loads the content without css and js when i refresh it…
doctorsherlock
  • 1,090
  • 1
  • 14
  • 32
14
votes
3 answers

Angular js - check if current url matches the route (with dynamic url params)

i'm simply doing setting this: app.config(['$routeProvider',function($routeProvider) { $routeProvider .when('/asd/:id/:slug',{ templateUrl:'views/home/index.html', controller:'Home', publicAccess:true, sessionAccess:true …
itsme
  • 45,343
  • 90
  • 210
  • 334
14
votes
2 answers

migrating from ngRoute/$routeProvider to ui-router/$urlRouterProvider

I want to start using Angular's ui-router instead of ngRoute. Originally, my app config looked like myApp.config(["$routeProvider", function($routeProvider) { $routeProvider .when("/search", { templateUrl:…
nshew13
  • 2,975
  • 4
  • 22
  • 37
14
votes
3 answers

Error: No module: ngRoute when trying to implement routing in angularjs

app = angular.module("dithat", ["ngRoute", "ngResource", 'ng-rails-csrf']); app.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/', { templateUrl: 'app/views/layouts/_user_page.html', controller:…
natecraft1
  • 2,453
  • 6
  • 34
  • 51
13
votes
1 answer

Migrate from ngRoute to ui-router

Needs some guidance with respect to migrating my ngRoute configuration to a ui.router configuration. Currently I have one main template (index.html) and it has an ng-view where all views are injected. My current ngRoute config is as…
user1491636
  • 2,057
  • 6
  • 34
  • 67
1
2 3
58 59