Select element from URL


#1

Hi all,

A question about URL routing, i have configured my page to display SUBNM selection when my SUBNM changes:
(according to Help article from Pulse website)

But when i copy changed URL from current page to a new page, the new page won’t retain my SUBNM selection and jump back to the first element in the SUBNM.
Does anyone know how to change the SUBNM selection according to URL? Ideally i hope the URL would determine the element being selected.

Thansk!
Tina


#2

Hi twu,
Please see code below that should help for the page to watch for change in the page at anytime with $watch function on ‘location.search()’ (once url changes the module attribute to lets say ‘Sales Plan’ (…localhost:8080/…?module=Sales%20Plan)

app.controller(‘someCtrl’, [’$scope’, ’ $location’, function($scope, $location) {

$scope.location = $location;
$scope.$watch('location.search()', function() {
    $scope.target = ($location.search()).module;
      
    $scope.filterSelected = $scope.target ;

}, true);

}


#3

Hi @twu,

Could you post in here the HTML code you have used for your SUBNM? Thanks.


Paul


#4

Hi @plim

My SUBNM as below:

<tm1-ui-subnm
         tm1-instance="FileUpload"
         tm1-dimension="Sys Upload Specification"
         tm1-subset="AllModules"
         tm1-change="setModule(data)"
         ng-model="page.titles.module"
         >
</tm1-ui-subnm>

#5

Hi @ishapiro

I have added the code to watch for url change, but how do i select element in <tm1-ui-SUBNM> when $scope.target changed?

Thanks
Tina


#6

Hi @twu,

Try to use and set the selected element via tm1-default-element. Just take note that it needs the element name (not alias).

For example:

<tm1-ui-subnm
         tm1-instance="FileUpload"
         tm1-dimension="Sys Upload Specification"
         tm1-subset="AllModules"
         tm1-change="setModule(data)"
         ng-model="page.titles.module"
         tm1-default-element="{{values.elementInUrlValue}}"
>
</tm1-ui-subnm>

Let us know how it goes.


Paul


#7

Hi @plim

Thanks! it worked.
Combining with the code @ishapiro provided, set default element to {{filterSelected}}.

Thanks both
Tina