angular-routing

Understanding what it takes to remove the hash # from angular routes

别说谁变了你拦得住时间么 提交于 2019-11-26 08:36:49
问题 Before removing the hash sign, I had mainApp.config(function ($locationProvider, $routeProvider) { $routeProvider .when(\'/page\', { controller: \'Page\', templateUrl: \'templates/page.html\' }) .when(\'/main\', { controller: \'Main\', templateUrl: \'templates/main.html\' }) .otherwise({ redirectTo: \'/main\'}); //$locationProvider.html5Mode(true); }); and these worked fine http://localhost:8080/index.html#/main http://localhost:8080/index.html#/page After removing the pound sign, I added to

How to get query parameters from URL in Angular 5?

帅比萌擦擦* 提交于 2019-11-26 06:27:55
问题 I\'m using angular 5.0.3, I would like to start my application with a bunch of query parameters. like \"/app?param1=hallo&param2=123\". Every tip given in How get query params from url in angular2? does not work for me. Any ideas how to get query parameters work? private getQueryParameter(key: string): string { const parameters = new URLSearchParams(window.location.search); return parameters.get(key); } This private function helps me to get my parameters, but I don\'t think it is the right

How to dynamically change header based on AngularJS partial view?

十年热恋 提交于 2019-11-25 23:28:40
问题 I am using ng-view to include AngularJS partial views, and I want to update the page title and h1 header tags based on the included view. These are out of scope of the partial view controllers though, and so I can\'t figure out how to bind them to data set in the controllers. If it was ASP.NET MVC you could use @ViewBag to do this, but I don\'t know the equivalent in AngularJS. I\'ve searched about shared services, events etc but still can\'t get it working. Any way to modify my example so it

$location / switching between html5 and hashbang mode / link rewriting

 ̄綄美尐妖づ 提交于 2019-11-25 22:27:35
问题 I was under the impression that Angular would rewrite URLs that appear in href attributes of anchor tags within tempaltes, such that they would work whether in html5 mode or hashbang mode. The documentation for the location service seems to say that HTML Link Rewriting takes care of the hashbang situation. I would thus expect that when not in HTML5 mode, hashes would be inserted, and in HTML5 mode, they would not. However, it seems that no rewriting is taking place. The following example does