angular-routing

AngularJS - get the list of defined routes - $routeProvider

烈酒焚心 提交于 2019-12-05 02:09:34
I am trying to implement named routes , so I don't have to write the whole path (often changes). I was thinking I could get away with writing a service that would return the list of defined routes and a filter that would transform object to aroute The use example would look like: <a ng-href="{id:1}|route:'detail'">Click here!</a> Provided I have added name:'detail' to my route definition, this would generate the following result : <a href="#/detail/1/">Click here!</a> I think this is quite simple, but: How can I get the list of defined routes ? I was thinking I can make use of routeProvider ,

Difference between router and router-deprecated in angular2

て烟熏妆下的殇ゞ 提交于 2019-12-05 01:40:47
I've updated from "beta.17" to "2.0.0-rc.1" and I don't understand when I should use router and when router-deprecated? UPDATE TO ANGULAR2 RC There are alot of changes has been made in routing in angular2 after RC some of them points i am going to mention here may help someone :- angular2/router has been changed with @angular/router (also you can use old functionality of routing using import of @angular/router-deprecated but as of now we have to use @angular/router ). @RouteConfig has been changed with @Routes . for example :- @Routes([ {path: '/crisis-center', component: CrisisListComponent},

Angular 5: remove route history

二次信任 提交于 2019-12-04 23:31:22
In my app I have a category page that has links to a various product list pages. If it turns out that when you get to a product list page there is only one product then it automatically navigates to that product detail page. What I want is to remove the product list page route in the history so that when the user is on the product detail page and hits the back button they will go to the category page and not the product list page because that will just redirect them back to the detail page. You can use angular routers replaceUrl flag to do this. See api docs for more details here this.router

How can I conditionally use either [href] or [routerLink] on an anchor?

旧时模样 提交于 2019-12-04 23:25:39
I need for the same anchor link to be pointed conditionally locally or to external resource. I tried <a [href]="outside?externalUrl:null" [routerLink]="outside?[]:['/route',id]" >test</a> But it doesn't work. I don't get any errors, but it points to the same local page and ignores the external URL. Any ideas? Another option would be to construct the link, but I can't find any docs how to access routerLink inside a service Edit: I know I can clone the whole link with *ngIf but I don't want to do it, my link contains a video tag with a buch of options developer033 The simplest way would be to

angular ng-view phonegap is not working

☆樱花仙子☆ 提交于 2019-12-04 21:40:34
I am trying to make basic app with angularjs and phonegap in android. But it doesn't seem to be working. Below are my source code files: index.html <!DOCTYPE html> <html ng-app="main-app"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <title>Insert title here</title> </head> <body> <div class="body-content" ng-controller="MainCtrl"> <div class="loader-ajax" ng-show="isViewLoading"></div> <div ng-view></div> </div> <script src="js/angular.js"></script> <script type="text/javascript

How do I check for login or other status before launching a route in Angular with routeProvider?

早过忘川 提交于 2019-12-04 19:31:33
问题 Let's say I have 4 routes - 2 require the user to be logged in, 2 do not. My app init looks like: $routeProvider.when('/open1',{templateUrl:'/open1.html',controller:'Open1'}); $routeProvider.when('/open2',{templateUrl:'/open2.html',controller:'Open2'}); $routeProvider.when('/secure1',{templateUrl:'/secure1.html',controller:'Secure1'}); $routeProvider.when('/secure2',{templateUrl:'/secure2.html',controller:'Secure2'}); Routes /open1 and /open2 are open to all, while routes /secure1 and

Angular 5 - Dynamic base reference is causing duplicate loading of bundles|chunks

时光毁灭记忆、已成空白 提交于 2019-12-04 19:14:51
问题 I am using Angular 5.2 version in the project. I am setting the base reference dynamically in the index.html to satisfy the different URL for different clients. The app main page url looks like this :- http://example.com/client1/app/login http://example.com/client2/app/login http://example.com/client3/app/login client1, client2 etc are virtual directories in the IIS. When i run the app in the browser, i can see from the inspect window that the duplicate chunks are getting loaded and causing

Angular 5 - Dynamic Route Added but not routing

扶醉桌前 提交于 2019-12-04 18:59:24
I have created a new project and added some code to to the routing module for dynamic routing: Here is the routing module code: import { NgModule } from '@angular/core'; import { Routes, RouterModule, Router} from '@angular/router'; import { OneComponent } from './one/one.component'; import { HomeComponent } from './home/home.component'; const routes: Routes = [ { path: 'home', component: HomeComponent }, ]; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) export class AppRoutingModule { constructor(router: Router, routerModule: RouterModule) { console.log(

Using angularJS with requireJS - cannot read property 'module' of undefined

被刻印的时光 ゝ 提交于 2019-12-04 14:53:22
问题 I had started writing an app using angularJS. After a few weeks, I suddenly realized that I should have used require JS from the beginning to load my modules. Yes, I know, it was stupid. But it is what it is. So I've tried to convert my code to suit requireJS now. This is my main.js requirejs.config({ baseUrl: "js", paths: { jquery:'jquery-1.7.min', angular: 'angular', angularRoute:'angular-route', mainApp:'AngularApp/app' }, priority:['angular'], shim:{ angularRoute:{ deps:["angular"] },

Angular routing with multiple routes and router-outlet

佐手、 提交于 2019-12-04 13:26:26
I'm trying to add navigation to components in addition to the navigation of the app root, but it is not navigating to component route. I'm using two router-outlet: router outlet for the app root (app.component.html) router outlet for users component (users.component.html) With two routes: route for the app (app.routing.module.ts) route for users (users.routing.module.ts) When navigating to " users " I can see users.component.html with two links, but when pressing on the link " list ", it is not navigating to: UsersListComponent defined in users.routing.module.ts I'm not sure if this is the