angular-routing

Angular Inject $http into config or provider into run

一个人想着一个人 提交于 2019-11-30 09:22:42
I am using angular-route-segment in my angular app and an trying to configure the segments from a json feed. I have having problems with this, because I can't figure out how to inject $http into the app.config function. This fails with Unknown provider: $http myApp.config(["$http", "$routeSegmentProvider", function ($http, $routeSegmentProvider) { /* setup navigation here calling $routeSegmentProvider.when a number of times */ } So instead of injecting $http into config , I also tried injecting $routeSegmentProvider into myApp.run myApp.run(["$http", "$routeSegment", function($http,

Get route parameters in component

蓝咒 提交于 2019-11-30 09:02:39
问题 I am working on the Angular-6 project. I have many child routes for my application. One of them is as follow: const routes: Routes = [ { path: 'innovation-track/:innovation-track-id', component: InnovationTrackComponent, children: [ { path: 'sprint', component: ScrumBoardComponent } ] } ]; I want to get innovation-track-id value from URL in my ScrumBoardComponent . I know I can get this by doing following: constructor(private _route: ActivatedRoute) { } //somewhere in method this._route

404 Not Found nginx angular routing

冷暖自知 提交于 2019-11-30 07:09:05
I Have an Angular application. I run the command ng build --prod --aot to generate the dist folder. In the dist folder I created a file named Staticfile then I uploaded the dist folder to pivotal.io with the following commands: cf push name-app --no-start cf start name-app The app runs well. I have a nav bar, so when I change the path with navbar everything works fine. But when I do it manually (I enter the url myself) I have this error 404 Not Found nginx . This my app.component.ts: const appRoutes: Routes = [ { path: 'time-picker', component: TimePickerComponent }, { path: 'material-picker',

angularjs ui-router stateparams invisible loses on page refresh

百般思念 提交于 2019-11-30 05:39:12
问题 Im working on a angular project, where i have set my states as shown below. $stateProvider.state('UserPanel', { url: '/user', params: { userId: null }, views: { 'content@': { templateUrl: '/AngViews/UserPanel/UserPanel.UserDetails.html' } } }); when i navigate to the view, it takes the params with it, so this part is working. But when i update the page, it's loses the params. I know that if i defined the params in the url variable it will work. but i want to make it invisible. I have found

How to prevent page refresh in angular 4

做~自己de王妃 提交于 2019-11-30 05:28:06
I want to prevent page refresh by everywhere. I tried the code below import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { CommonServices } from '../services/common.service'; @Component({ selector: 'app-review-prescription', templateUrl: './review-prescription.component.html', styleUrls: ['../../assets/css/prescriptionView.css'], providers:[ CommonServices ] }) export class ReviewPrescriptionComponent implements OnInit { constructor( private commonServices:CommonServices, private router:Router ){} ngOnInit(){ window.onbeforeunload = function

Property 'url' does not exist on type 'Event' for Angular2 NavigationEnd Event

南笙酒味 提交于 2019-11-30 05:17:23
问题 this.subscription = this.router.events.subscribe((event:Event) => { console.log(event.url); ##### Error : Property 'url' does not exist on type 'Event'. } Typescript doesn't recognize the properties of the type Event that is built into the Angular Router. Is there something on tsd that I can use to solve this? Event is the super class of classes NaviagationEnd, NavigationStart 回答1: You have to import { Event } from @angular/router; . Try moving console into the if block with condition. this

How to trace routing in Angular 2?

一笑奈何 提交于 2019-11-30 04:43:39
I have component with separated file of routing settings: import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { Route } from '../core/route.service'; import { extract } from '../core/i18n.service'; import {CalendarThematicPlanComponent} from './calendar-thematic-plan.component'; const routes: Routes = Route.withShell([ { path: 'calendar', component: CalendarThematicPlanComponent } ]); @NgModule({ imports: [RouterModule.forChild(routes)], exports: [RouterModule], providers: [] }) export class CalendarThematicPlanRoutingModule { } When I

Angularjs dependency injection in resolve

寵の児 提交于 2019-11-30 03:52:27
I would like to use proper dependency injection in MyCtrl1 to inject the fields of the MyCtrl1.resolve object. I've tried many different combinations of attempting to inject @MyCtrl1.resolve etc. with no luck. @MyCtrl1 = ($scope, $http, batman, title) -> $scope.batman = batman.data $scope.title = title.data @MyCtrl1.resolve = { batman: ($http) -> $http.get('batman.json') title: ($http) -> $http.get('title.json') } #@MyCtrl1.$inject = ['$scope', '$http'] -- commented out because not sure how to inject resolve fields angular .module( 'app', []) .config( ['$routeProvider', '$locationProvider', (

Angular 2 Jasmine Can't bind to 'routerLink' since it isn't a known property of 'a'

夙愿已清 提交于 2019-11-30 00:17:53
问题 I'm creating a unit test for my Navbar Component and I'm getting an error: Can't bind to 'routerLink' since it isn't a known property of 'a' Navbar Component TS import { Component } from '@angular/core'; import { Router } from '@angular/router'; import { NavActiveService } from '../../../services/navactive.service'; import { GlobalEventsManager } from '../../../services/GlobalEventsManager'; @Component({ moduleId: module.id, selector: 'my-navbar', templateUrl: 'navbar.component.html',

How to implement multi-level routing in Angular?

ε祈祈猫儿з 提交于 2019-11-29 15:34:56
问题 I'm working on a little project of mine in order to learn something more about Angular, but I really cannot figure out how to implement a multi-leveled routing. I've read the documentation about the new release of the Router Component and also some other topics on StackOverlfow (first, second, third), but I cannot find a solution to my problem. Let's consider the following app structure , without considering the Test and Test2 blocks. And let's consider the components of my app as following: