javascript - Angular 2, TypeScript & ui-router - How to get state params -


hey wondering how state params state using angular 2, typescript & ui-router. tried reviewing new docs don't seem have documentation ng2 ui-router.

below have added component.ts reference. appreciated.

import {component} '@angular/core'; import {http_providers} '@angular/http'; import {uirouter} 'ui-router-ng2/router';  @component({   selector: 'detail',   template: require('./detail.html'),   providers: [http_providers] })  export class detail {   constructor(private uirouter:uirouter) {     console.log('uirouter ', this.uirouter.globals.params);   } } 

in angular 1 follows:

(function() {   'use strict';    angular   .module('private')   .controller('controller', controller);    function controller($state) {     var vm = this;     console.log($state.params.studentid);   } })(); 

again advice appreciated.

i able resolve state param issue having doing following:

import {component} '@angular/core'; import {http_providers} '@angular/http'; import {uirouter_directives} 'ui-router-ng2'; import {uirouter} 'ui-router-ng2/router';  @component({   selector: 'detail',   template: require('./detail.html'),   directives: [uirouter_directives],   providers: [http_providers] })  export class detail {     public detailparam: any;      constructor(private uirouter:uirouter) {       this.detailparam = this.uirouter.globals.params;       console.log('state params: ', this.detailparam);   } } 

but after little more research found better documentation on ui-router angular 2 here: https://ui-router.github.io/ng2/

looks correct way of dealing state params with

import {transition} "ui-router-ng2" 

and using

trans.params().detailid 

i not able trans.params() work @ particular moment @ least found temporary solution , better documentation find proper solution.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -