angularjs-ng-route

Angular routes contain #! in the url instead of # [duplicate]

馋奶兔 提交于 2019-11-29 03:30:08
This question already has an answer here: angularjs 1.6.0 (latest now) routes not working 5 answers 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 disable the requireBase which removes the base as a whole using the code, $locationProvider.html5Mode({ enabled: true, requireBase: false }); and the URL changes to www.website.com/login which works fine but is misleading and is not what Angular SPA

Angular 5 - redirect page to homepage on browser refresh

馋奶兔 提交于 2019-11-28 19:25:05
Currently, when I refresh a page from a route like http://localhost:4200/feedback it stays on the same route. But I want the route to redirect to http://localhost:4200 I saw people have asked how to implement the refresh to stay on the same route. So I guess, the default angular should redirect to homepage on browser refresh. Any idea why my angular default project does this otherwise? Below is my AppRoutingModule import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { SmileyFeedbackComponent } from '../smiley-feedback/smiley-feedback

Angular routes contain #! in the url instead of # [duplicate]

与世无争的帅哥 提交于 2019-11-27 17:36:00
问题 This question already has an answer here: angularjs 1.6.0 (latest now) routes not working 5 answers 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 disable the requireBase which removes the base as a whole using the code, $locationProvider.html5Mode({ enabled: true, requireBase: false }); and

Angular 5 - redirect page to homepage on browser refresh

五迷三道 提交于 2019-11-27 12:17:34
问题 Currently, when I refresh a page from a route like http://localhost:4200/feedback it stays on the same route. But I want the route to redirect to http://localhost:4200 I saw people have asked how to implement the refresh to stay on the same route. So I guess, the default angular should redirect to homepage on browser refresh. Any idea why my angular default project does this otherwise? Below is my AppRoutingModule import { NgModule } from '@angular/core'; import { RouterModule, Routes } from

How to change page title in Angular using $routeProvider

寵の児 提交于 2019-11-27 11:46:13
问题 I found several similar questions, however none of the answers helped. They all seem to involve some type of $location dependencies that I'm unable to get injected right. My code below: (function() { // App dependencies var app = angular.module('portalExchange', ['ngRoute', 'app-products', 'app-manage', 'app-profile']); // [ Main Controller ] : PortalController app.controller('PortalController', function($scope) { if ($('.top_link_dashboard').hasClass('unactive_top')) { $('.top_link_dashboard

How/when to use ng-click to call a route?

ぐ巨炮叔叔 提交于 2019-11-27 05:50:33
Suppose you are using routes: // bootstrap myApp.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { $routeProvider.when('/home', { templateUrl: 'partials/home.html', controller: 'HomeCtrl' }); $routeProvider.when('/about', { templateUrl: 'partials/about.html', controller: 'AboutCtrl' }); ... And in your html, you want to navigate to the about page when a button is clicked. One way would be <a href="#/about"> ... but it seems ng-click would be useful here too. Is that assumption correct? That ng-click be used instead of anchor? If so, how would that

How/when to use ng-click to call a route?

淺唱寂寞╮ 提交于 2019-11-26 11:45:49
问题 Suppose you are using routes: // bootstrap myApp.config([\'$routeProvider\', \'$locationProvider\', function ($routeProvider, $locationProvider) { $routeProvider.when(\'/home\', { templateUrl: \'partials/home.html\', controller: \'HomeCtrl\' }); $routeProvider.when(\'/about\', { templateUrl: \'partials/about.html\', controller: \'AboutCtrl\' }); ... And in your html, you want to navigate to the about page when a button is clicked. One way would be <a href=\"#/about\"> ... but it seems ng

AngularJS routing 404 error with HTML5 mode

眉间皱痕 提交于 2019-11-26 10:57:56
I just got started with angular js , i tried routing and worked pretty well .The problem is when i refresh the page it is showing 404 error since it is checking in my actual directory rather than checking in routes. here is the complete code <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script> <body ng-app="myApp"> <base href="/" /> <a href="blue">blue</a> <a href="green">green</a> //blue.html and green.html are in same directory as