cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

fill select widget with for loop

GianVal
13-Aquamarine

fill select widget with for loop

I want to fill the 

$scope.view.wdg["select-1"].list

with a for loop.

just like i can do with the following method. 

var title = []; for(var i = 0; i < array.length; i++) { title[i] = { name: array[i], value: i+1 }; }

 

How can I do?

1 ACCEPTED SOLUTION

Accepted Solutions

both approaches are working and your code show work - not sure what is not working for you 

 

$scope.colors = function () {

        var listOfColors = [
              {display: "Red",value: "red"},
              {display: "Green",value: "green"},
              {display: "Blue",value: "blue"}
       ]

        $scope.view.wdg.colorSelector.list = title;
}

$scope.$on("$ionicView.afterEnter", function (event) {
$scope.view.wdg["colorSelector"].list = title;
});

// or 

$scope.$on('modelLoaded', function (evt, arg) {
     $scope.colors();

});

View solution in original post

2 REPLIES 2
sebben
12-Amethyst
(To:GianVal)

Hi,

you can do it like this:

var array = ["a","b","c"]
var title = []; 
for(var i = 0; i < array.length; i++)
{ title[i] = { display: array[i], value: i+1 }; }
$scope.$on("$ionicView.afterEnter", function (event) {
$scope.view.wdg["select-1"].list = title;
});

both approaches are working and your code show work - not sure what is not working for you 

 

$scope.colors = function () {

        var listOfColors = [
              {display: "Red",value: "red"},
              {display: "Green",value: "green"},
              {display: "Blue",value: "blue"}
       ]

        $scope.view.wdg.colorSelector.list = title;
}

$scope.$on("$ionicView.afterEnter", function (event) {
$scope.view.wdg["colorSelector"].list = title;
});

// or 

$scope.$on('modelLoaded', function (evt, arg) {
     $scope.colors();

});

Announcements

Topics available:
AR/VR for Data Optimization AR/VR for Security and Control AR/VR for Inspection