Hi i am learning ionic framework for mobile app development & have doubt in formulating the query for options to show.
Query Html:
<select ng-repeat="formEach in form" ng-options="f.FormId as f.Formname for f in form"></select>
My form array is this:
var form= [{Teamid : 1, Teamname :'First team', Formid: X0001, Formname : 'sample form 1'},
{Teamid : 2, Teamname :'Second team', Formid: X0002, Formname : 'sample form 2'},
{Teamid : 3, Teamname :'Third team', Formid: X0003, Formname : 'sample form 3'},
{Teamid : 4, Teamname :'Fourth team', Formid: X0004, Formname : 'sample form 4'}];
If you have an array you can use ng-options like this :
<select ng-model="Formid" ng-options="f as f.Formname for f in form"></select>
Look this example
No need to use ng-repeat and ng-options together. Also, set the model that will contain the selected option.
<select ng-model="Formid" ng-options="f.Formid for f in form track by f.Teamid"></select>
Your controller should look something like this..
var app = angular.module('myApp', []);
app.controller('myController', function ($scope) {
$scope.form = [{
Teamid: 1,
Teamname: "First team",
Formid: "X0001",
Formname: "sample form 1"
}, {
Teamid: 2,
Teamname: "Second team",
Formid: "X0002",
Formname: "sample form 2"
}, {
Teamid: 3,
Teamname: "Third team",
Formid: "X0003",
Formname: "sample form 3"
}, {
Teamid: 4,
Teamname: "Fourth team",
Formid: "X0004",
Formname: "sample form 4"
}];
});