angular-routing

Angular Router Events: NavigationEnd — How to filter only the last event

*爱你&永不变心* 提交于 2019-12-06 08:26:11
I want to extract only the last event entry of type NavigationEnd from router.events. But somehow I can't find a proper way to do this. Whatever I try the following code snipped is the only way to get access to these objects of interest. let ne: any; router.events.filter(e => e instanceof NavigationEnd) .forEach(e => { ne = e as NavigationEnd; }); console.log('target page: ', ne.urlAfterRedirects); But do I really have to use .forEach() letting it run though all entries and using then the last entry? Isn't there a better way to handle the events as a kind of array and then say ne =

angularjs route - jump to specific page section on route link

孤街醉人 提交于 2019-12-06 06:45:59
问题 I am trying to make some kind of a mix between an Angular anchor and routing... I do have it working in the home page, since the anchor sections are there, however, if I am in another page, it does not. Can anyone point me in the right direction on how to do it correctly, please? Here´s what I have so far freddoApp.config(function($routeProvider, $locationProvider) { $routeProvider // route for the home page .when('/', { templateUrl : 'pages/home/home.html', controller : 'mainController' }) /

Angular 2 — navigate through web pages without reloading a component that is common for those pages

送分小仙女□ 提交于 2019-12-06 06:08:52
Here you can find an example app: http://ivan-khludov.com/ This is my root component: import { Component } from '@angular/core'; @Component({ selector: 'root', template: ` <h1>My Dummy Angular App</h1> <router-outlet></router-outlet> <nav> <a routerLink="/section-1/1" routerLinkActive="active">Section 1 - Page 1</a> <span>||</span> <a routerLink="/section-1/2" routerLinkActive="active">Section 1 - Page 2</a> <span>||</span> <a routerLink="/section-2/1" routerLinkActive="active">Section 2 - Page 1</a> <span>||</span> <a routerLink="/section-2/2" routerLinkActive="active">Section 2 - Page 2</a>

Nested parameterized routes with ui-router in AngularJS

我们两清 提交于 2019-12-06 05:52:47
I believe I'm on the right track with these terms, "nested parameterized routes", but haven't found what I'm looking for yet. My objective is to create intuitive routes for my API, something like the following example: /api/v1/project/list /api/v1/project/1/item/list /api/v1/project/1/item/1/edit /api/v1/project/2/item/3/delete It's relatively easy and clear how to setup project states, but not the item states within each project. { state: 'project' config: { url:'/project' } }, { state: 'project.list' config: { url: '/list' } }, { state: 'project.detail' config: { url: '/:project_id' } } It's

Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'site-notice'

老子叫甜甜 提交于 2019-12-06 05:45:43
问题 Im totaly confused about this error. I have a very basic simple routing: const routes: Routes = [ { path: '', component: FrameDefaultComponent, pathMatch: 'full', children: [ {path: '', component: SiteCalculatorComponent}, {path: 'site-notice', component: SiteSiteNoticeComponent} ] }, ]; When i click the menu entrie for site-notice in the menu that looks like this: menuEntries = [ { title: 'Calculator', url: '/' }, { title: 'Site Notice', url: '/site-notice' } ]; Then i get the following

Does AngularJS have dynamic routing?

末鹿安然 提交于 2019-12-06 05:43:41
问题 Does angular support dynamic routing at all? Maybe some trick like this: $routeProvider.when('/:ctrl/:action', getRoute($routeParams.ctrl,$routeParams.action)) function getRoute(ctrl, action){ return { templateUrl: ctrl+"-"+action+".html" controller: 'myCtrl' } } Please help me, I need to get templateUrl based out of routeParams 回答1: This is a late answer but I came across this problem myself, but it turns out that the solution by Dan conflicts with ngAnimate classes on the ngView directive,

External Links in Angular App

老子叫甜甜 提交于 2019-12-06 04:02:43
I'm in the process of incorporating Angular into a single page of an existing rails app. Everything is working perfectly with the routing within the page using the following app.config(function($routeProvider, $locationProvider) { $routeProvider .when('/services/:id', { templateUrl: "/javascripts/angular/templates/service_ui/service.html", controller: "ServiceCtrl" }) $locationProvider.html5Mode(true); }); However, I'd like to maintain normal functionality for links that are not related to Angular. For example, we have a number of links in the header that link elsewhere that are now being

Angular - How can I activate AUX route with lazy loaded module?

天大地大妈咪最大 提交于 2019-12-06 02:44:48
问题 I have an angular app which is loading lazily module. At first the app is navigating to home where it loads the module ( named module1 ) : main routing : const routes: Routes = [ { path: "", redirectTo: "/home", pathMatch: "full" }, { path: "home", loadChildren: "./module1/module1.module#Module1Module" }, ]; At module1 - there's also routing table : const routes: Routes = [ { path: "", component: Home1Component, children: [ { path: 'bird', outlet: 'under', component: Home2Component } ] } ];

Angular UI Router Reload Controller on Back Button Press

拥有回忆 提交于 2019-12-06 02:33:49
问题 I have a route that can have numerous optional query parameters: $stateProvider.state("directory.search", { url: '/directory/search?name&email', templateUrl: 'view.html', controller: 'controller' When the user fills the form to search the directory a function in the $scope changes the state causing the controller to reload: $scope.searchDirectory = function () { $state.go('directory.search', { name: $scope.Model.Query.name, email: $scope.Model.Query.email }, { reload: true }); }; In the

import html template in typescript

Deadly 提交于 2019-12-06 01:41:19
I'm trying to import my html template so that webpack will recognize them and include them when I build. ( webpack -d ) According to this GitHub issue I should do this declare module '*.html' { const _: string; export default _; } Then import template from './myTemplate.html'; should work. But it doesn't quite do the trick. import template from './myTemplate.html'; console.log(template); // undefined However this "works" import * as template from './myTemplate.html'; console.log(template); // <p>Hello world!</p> Very strange. But now this doesn't work $routeProvider.when("/test", { template: