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
Post a Comment