angular-routing

angular ng-view phonegap is not working

本秂侑毒 提交于 2019-12-06 16:57:17
问题 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

Angular4 - Nested route with params

久未见 提交于 2019-12-06 15:21:19
I got a routing for my user profiles in Angular4 /* Frame Default */ { path: '', component: FrameDefaultComponent, children: [ {path: 'home', component: SiteHomeComponent}, {path: 'home/:page', component: SiteHomeComponent}, { path: 'user/:id', component: SiteUserProfileComponent, children: [ {path: '', redirectTo: 'home', pathMatch: 'full'}, {path: 'home', component: SiteUserProfileHomeComponent}, {path: 'about', component: SiteUserProfileAboutComponent} ] }, { path: 'user/settings', component: SiteUserSettingsComponent, children: [ {path: '', redirectTo: 'home', pathMatch: 'full'}, {path:

How to correctly implement multiple views with UI Router in Angular?

荒凉一梦 提交于 2019-12-06 14:59:09
I'm trying to implement a site with two main content 'panes' (imagine two columns each half the width of the page). The panes should be able to change independent of each other and have their own controllers and be able to pass data between each other (so the user can navigate through a bunch of pages on the left pane while the right pane stays the same without reloading and vice versa, and a change in the left pane can update data showing up in the right pane). I've looked through a bunch of examples/tutorials on UI Router but can't seem to find a good example of how to implement what I'm

How to redirect to logout when token expired in angular 4

浪子不回头ぞ 提交于 2019-12-06 14:16:20
I have a angular 4 application. There i use JWT token for authentication purposes. Everything works fine. but the token expiration time i have given to the JWT toke is 1 hour. i want to log the user out from the front end application once the token expired in the server side. in node backend i use express middlewere to hanndle this by checking if all the requests contain a valid token. Is there a way to do this angular side as well? You can use Http Interceptors. If any Unauthorized 401 response. Suppose you are sending a http request with token in header. your server side code check your

Angular2 navigate from a component to a sibling component without tearing down the first

元气小坏坏 提交于 2019-12-06 11:26:32
I've just started learning Angular2 and I want to build a very common "list-detail" style page similar to this: http://xgrommx.github.io/rx-book/index.html . When you click an item in left-bar it initiates a navigation to the center detail view without tearing down the left-bar. What's the best way to achieve this effect? My current design is like the following: When I start the home component, the list component(child1) will load immediately and it will call an external API to fetch the names (only names) of a list of items. When clicking a item name on the left, it will create a new Detail

How do I load UI-router ui-view templates that are nested 3 states deep?

混江龙づ霸主 提交于 2019-12-06 10:25:19
问题 I am attempting to design the routing and nested views in my app several levels deep in order to replace parts of the app based on a route. I'm able to load the login page, and it seems the layout view loads as well, however, I can't seem to get the nested <ui-view /> tags to work. Can someone please tell me how I'm doing this wrong, or if there is a more idiomatic way in Angular to accomplish the same functionality. app.js (function() { 'use strict'; angular .module('webApp', [ 'ui.router',

Ionic 4 routing with angular 6

蓝咒 提交于 2019-12-06 09:45:17
问题 Im trying to update a legacy ionic app to v4 at the moment but cant seem to find a v4 equivalent to this navigation return this.app.getRootNav().setPages([ {page: Profile}, {page: SettingsPage, params: {id: userId}} ]) 回答1: Ionic4 and angular version of your request is like this : this.router .navigate(["/page1"], { replaceUrl: true }) .then(() => this.router.navigate(["/page2"])); The logic is here as i understand. Push page1 into history but navigate to page2 so if user pushes the back

angular2 router navigation does not load component properly

浪子不回头ぞ 提交于 2019-12-06 09:11:36
My code for that is as shown below: googleClick(): void { this._auth.login('google').subscribe( (data: any) => { console.log('google server data ' + JSON.stringify(data)); this.loginService.registerUser(data.email, data.name, '0').subscribe(res => { if (res.status === '200') { this.storage.store('user_token', res.data.user_token); this.storage.store('user_email', data.email); this.storage.store('user_img', data.image); this.storage.store('user_first_name', res.data.user_name); this.storage.store('user_id', res.data._id); this.storage.store('user_paltform_login', 0); this.router.navigate(['

Angular 2 Router - CanActivate Guard

允我心安 提交于 2019-12-06 09:06:21
问题 I'm implementing a CanActivate guard to redirect the user to the login page if their session is invalid. The check as to whether the session is valid or not is done through a service and so from the guard I'm subscribing to the service call to get the session validity state. I've debugged the code and everything seems to be working as it should, in fact when the session is invalid the app does redirect back to the login page. However when I return true from the guard, the page is not loaded.

Angular routing with multiple routes and router-outlet

£可爱£侵袭症+ 提交于 2019-12-06 08:31:55
问题 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