Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
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?
Solved! Go to Solution.
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();
});
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();
});