angular-routing

Angular Inject $http into config or provider into run

瘦欲@ 提交于 2019-12-30 03:16:13
问题 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

Angular2 - APP_BASE_HREF with HashLocationStrategy

社会主义新天地 提交于 2019-12-29 05:27:28
问题 I have an angular application uses routing with HashLocationStrategy, I need to set different value in main html file and different in routing. I tried this solution: @NgModule({ imports: [ BrowserModule, FormsModule, HttpModule, MyRouting // with useHash set to true ], declarations: [ AppComponent, ], providers: [ { provide: APP_BASE_HREF, useValue: '/prefix' } ], bootstrap: [AppComponent] }) export class AppModule { } Works almost well but value '/prefix' is insert after hash, like this:

Elegant way to access the caption associated with a router link in Angular

半腔热情 提交于 2019-12-25 14:57:22
问题 I'm wanting to display the currently selected link caption where the text Page Title currently is and wondered if there was an elegant way to do it. import { Component } from '@angular/core'; @Component({ template: `<div class="container"> <div class="sub-navigation"> <h1>Page Title </h1> <nav> <ul> <li *ngFor="let item of settingsMenu"><a [routerLink]="item.link" routerLinkActive="router-link-active" #rla="routerLinkActive" href=""><i ngClass="{{item.style}}" aria-hidden="true"></i> {{item

How can I create an AngularJS SPA application that does not use routing?

北城以北 提交于 2019-12-25 12:21:10
问题 I would like to create an AngularJS application that's uses just the one HTTP domain with nothing after the .com. For example an application where this is the only URL that displays in the browser: www.myapp.com Is this possible and what would I need to do this? All of the applications I have seen so far use something like: www.myapp.com/users www.myapp.com/screen1 etc. 回答1: Sure; all you need is some kind of top-level application state and UI that responds to that state. That's all ngRoute

Issue with ngRoute injecting resolve services into component controller

跟風遠走 提交于 2019-12-25 12:12:37
问题 I am trying to inject a service into a controller using the resolve property of $routeProvider but I am getting this error when I run it. Any suggestion would be great. Thanks in advance. Error: [$injector:unpr] Unknown provider: messageProvider <- message GitUserService.js module.exports = function (app) { app.factory('GitUser', ['$http', function ($http) { return { GetGitUser: function (username) { return $http.get('https://api.github.com/users/' + username) .then(function success(response)

Issue with ngRoute injecting resolve services into component controller

为君一笑 提交于 2019-12-25 12:10:05
问题 I am trying to inject a service into a controller using the resolve property of $routeProvider but I am getting this error when I run it. Any suggestion would be great. Thanks in advance. Error: [$injector:unpr] Unknown provider: messageProvider <- message GitUserService.js module.exports = function (app) { app.factory('GitUser', ['$http', function ($http) { return { GetGitUser: function (username) { return $http.get('https://api.github.com/users/' + username) .then(function success(response)

Angular 2 Multiple layout routing

让人想犯罪 __ 提交于 2019-12-25 11:05:28
问题 On my angular 2 app, I have a completely different layout between my home page and the rest of the app. The rest of the app have only a nav in common. My url looks like : http://localhost:4200/ <== this is my home page http://localhost:4200/cgu <== a page with nav in common http://localhost:4200/abc <== a page with nav in common Can someone explain to me the best way to do this ? I tried to reproduce this solution : How to switch layouts in Angular2 But it doesn't work, or I made mistake to

Angular2 refresh router-outlet

自古美人都是妖i 提交于 2019-12-25 09:19:47
问题 I'm working on a CRM and I have a select box in the header which allows the user to change the current user, In addition, the main content is inside the router-outlet. When the user select another user I want to refresh the page but only the router-outlet so the info will be for the new user I saw that other CRMs just redirect the user to the dashboard / index page, but I want to keep the user on the same page. 回答1: You should have a function in a service import {Subject} from 'rxjs/Subject';

Loading angular js internal routes and controllers

好久不见. 提交于 2019-12-25 04:26:28
问题 I have an issue with the routes and controller. If I have a route like below this-> .state('dashboard/profile', { url: '/dashboard/profile', parent: 'common', //templateUrl: '/app/dashboard/dashboard.html', template: '<div><h4>dashboard/profile</h4></div>', controller: 'ProfileCtrl' }) Now as I will be having many routes,I want to load all the routes inside dashboard only after the user reaches dashboard.html page.If I follow as above I will have to load all the routes even when not needed

$location.search is not updated imediatly

余生长醉 提交于 2019-12-25 03:26:10
问题 I have a problem that my url doesn't get updated every time i set it. It is somehow connected with the directive, because in other cases it works. So my question is, on what is the $location.search('dd', val) depended on, what is it waiting for, because function gets called, but the url is not updated. 回答1: it waits for a digest.. $scope.$apply(function() { $location.search('dd', val) }) 来源: https://stackoverflow.com/questions/24572613/location-search-is-not-updated-imediatly