angular-routing

How to use ng-switch as a router for my pages with ngRoute & ngView?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 11:54:39
问题 Here is the highlevel skeleton of my Angular SPA. My application is about college degree offerings. In that engineering page has a separate left nav which is currently built on ng-switch which i want to convert as route. How do i do that just using angular's native routing angular-route.js? **app.js** (function(){ var app=angular.module("myCollege",['ngRoute']); app.config(['$routeProvider','$locationProvider', function($routeProvider,$locationProvider) { $routeProvider .when('/', {

History push state redirects instead of just pushing new state to browser history

删除回忆录丶 提交于 2019-12-19 10:32:30
问题 I am trying to push a new state to browser history on my APP initialization but while pushing the state it also redirects the page which is not required. Here is a demo working app. https://angular-tet5fy.stackblitz.io/page2?fbclid=IwAR1zP_UTnCQxKMp8o3ZXf-n4NR3ftu_4JoulLqItaONa-_wSPJ_DT95OgRU This is the code: ngAfterViewInit() { console.log('init called'); var x = document.referrer; console.log('ref', x); if (x) { console.log('pushing state'); this.location.pushState({id:'page3'}, 'Page3', '

History push state redirects instead of just pushing new state to browser history

江枫思渺然 提交于 2019-12-19 10:32:08
问题 I am trying to push a new state to browser history on my APP initialization but while pushing the state it also redirects the page which is not required. Here is a demo working app. https://angular-tet5fy.stackblitz.io/page2?fbclid=IwAR1zP_UTnCQxKMp8o3ZXf-n4NR3ftu_4JoulLqItaONa-_wSPJ_DT95OgRU This is the code: ngAfterViewInit() { console.log('init called'); var x = document.referrer; console.log('ref', x); if (x) { console.log('pushing state'); this.location.pushState({id:'page3'}, 'Page3', '

Angular 4 Lazy Loading with parameters

血红的双手。 提交于 2019-12-19 02:07:11
问题 Hello I am attempting to lazy load a "detail module" while also sending parameters via the URL. Here is my lazy loaded route: { path: 'venue/:name/:id', loadChildren: () => System.import('../containers/activity-detail/activity-detail.module').then((file: any) => { return file.default; }) }, I would like to route to this 'activity-detail.module' and then load details using the ":name", and "id:" parameters. The module which loads has its own routes file. export const VenueDetailRoutes: Route[]

How to get checkbox value in angularjs?

半腔热情 提交于 2019-12-18 19:15:05
问题 I have a 10(or n)checkbox in my ng-view. Now I would like to ask here that What is the most efficient or simple way to check if checkbox is checked and if checked get the value of checkbox. <ul> <li ng-repeat="album in albums"> <input type="checkbox" ng-model="folder.Selected" value={{album.name}} /> </li> </ul> I have ng-controller(getAlbumsCtrl) , in that I have an array in which I want to push all the checkedbox albums names into albumNameArray 回答1: You can loop over the array to find out

Angular 5: remove route history

烈酒焚心 提交于 2019-12-18 18:59:46
问题 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.

Routing in Angular2 - Link “['Name']” does not resolve to a terminal instruction

半腔热情 提交于 2019-12-18 14:34:44
问题 I am trying to get a simple app working with child routing. When I setup the routes on my child component I get the following error message: Link "["ChildItem"]" does not resolve to a terminal instruction If I place all the routes on the parent component it works correctly. If I split the routes between the child and parent components I get the above error. Here is it working with all routes on the same component: import {bootstrap} from 'angular2/platform/browser'; import {Component, provide

Routing in Angular2 - Link “['Name']” does not resolve to a terminal instruction

。_饼干妹妹 提交于 2019-12-18 14:33:11
问题 I am trying to get a simple app working with child routing. When I setup the routes on my child component I get the following error message: Link "["ChildItem"]" does not resolve to a terminal instruction If I place all the routes on the parent component it works correctly. If I split the routes between the child and parent components I get the above error. Here is it working with all routes on the same component: import {bootstrap} from 'angular2/platform/browser'; import {Component, provide

Angular ActivatedRoute data returns an empty object

风流意气都作罢 提交于 2019-12-18 12:45:44
问题 I have a route registered with some data: const routes: Routes = [ {path: 'my-route', data: { title: 'MyTitle' }, component: MyComponent}, ]; and I'm trying to access to the route's data using ActivatedRoute : import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; @Component({...}) export class MyComponent implements OnInit { private routeData; constructor(private route: ActivatedRoute) {} ngOnInit() { this.routeData = this.route.data.subscribe(

How to prevent page refresh in angular 4

心不动则不痛 提交于 2019-12-18 11:43:10
问题 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