Use page filter selection in CellGet/CellPut in JS

Hi all,
One question about relation between html and js file with CellPut and CellGet functions.

I would like to use the page filter ng-model from a ui-tm1-subnm as part of my slider function in the js file, but I do not know how to make it.

HTML File codes:

  <div class="col-md-2">               
      <div class="input-group">
           <span class="input-group-addon" id="basic-addon1"><i class="fa fa-globe"></i></span>
                  <div style="font-family: Segoe UI; font-size:11pt; font-style:normal">                     
                              <tm1-ui-subnm
                                        tm1-instance="dev"
                                        tm1-dimension="Zone"
                                        tm1-subset="All Members"
                                        tm1-default-element="Russia"
                                        ng-model="page.Zone">
                               </tm1-ui-subnm>
                     </div>
            </div>
        </div>
     </div>

In my js file, here is the code where I need to replace ‘Russia’ by ng-model selection

app.controller('sliderCtrl', ['$scope', '$rootScope', '$log', '$tm1Ui', function ($scope, $rootScope, $log, $tm1Ui) {
 
$tm1Ui.cellGet('dev', 'Channel Share', 'E-commerce', 'Scenario 1', 'Russia', 'Change in Share').then(function (data) {
        var value;
        value=data.Value;
    
        $scope.slider = {
            value: value,
            options: {
                showSelectionBar: true,
                floor: 0,
                ceil: 10000,
                step: 0.1,
                translate: function(value) {
      console.debug(value);
      return accounting.formatNumber(value/100, 2, ".", ",") + '%';
    }           
            }
        };
 
    });
 
    $scope.$on("slideEnded", function () {
        var samevalue = $scope.slider.value / 10000;
        samevalue = '0,' + samevalue;
        console.debug('value| ' + samevalue);
        $tm1Ui.cellPut(samevalue, 'dev', 'Channel Share', 'E-commerce', 'Scenario 1', 'Russia', 'Change in Share');
        $tm1Ui.dataRefresh();
    });

I’ve tried this, but it doesn’t work:

$tm1Ui.cellGet('dev', 'Channel Share', 'E-commerce', 'Scenario 1', $scope.page.Zone, 'Change in Share').then(function (data) {

Any idea ?
Thanks for your help.

Hi @sschreurs,

Note that: the JS file loads first before the HTML.

So this means that at the time the cellGet ran, the $scope.page.Zone will not work (I imagine that there is an error in the console saying something like ‘undefined’).

Try this out:

In the JS, initialize the variable by putting this just before the above codes:

$scope.page = {
Zone: ‘Russia’
};

Then in the HTML, change the attribute into:

tm1-default-element="{{page.Zone}}

Let me know how it goes.

Cheers!
Paul

Hi Paul,

Yes it works.
Thanks for your help !
S.