I have ngOptions in one of my select elements connected to an array I made in the controller, and it's just not showing any values. I must be doing something stupid.
I know for sure that Angular is working, and the controller must be working because I use an expression related to an ngModel in the same div (using the same controller) and it works fine.
This is the relevant snippet of my html:
<div class="container" ng-app="tagQuestionnaireApp"> <div class="tagger" ng-controller="taggingController"> <form class="form-horizontal" name="tagForm" role="form"> <!-- Categorize Your Tag --> <div class="form-group"> <label class="sub" for="categorize">Categorize</label> <select class="form-control" id="categorize" ng-model="category" ng-options="cat.text in cat of categories"></select> </div> </form> </div> </div>
This is my js file:
var tagQuestionnaireApp = angular.module('tagQuestionnaireApp', []);
tagQuestionnaireApp.controller('taggingController', ['$scope', function($scope) {
$scope.categories = [
{text:'Humanities', topics:[{name:"Arts and Design",color:"#ff3d00"},
{name:"History",color:"#ffc107"},
{name:"Linguistics",color:"#ffab00"},
{name:"Literature",color:"#ff7043"},
{name:"Philosophy",color:"#dd2c00"},
{name:"Theology",color:"#ff6f00"},
{name:"Other Humanities",color:"#ff5722"}]},
{text:'Social Sciences', topics:[{name:"Anthropology",color:"#"},
{name:"Archaeology",color:"#"},
{name:"Cultural/Ethnic/Area Studies",color:"#"},
{name:"Economics",color:"#"},
{name:"Gender/Sexuality Studies",color:"#"},
{name:"Geography",color:"#"},
{name:"Political Science",color:"#"},
{name:"Psychology",color:"#"},
{name:"Sociology",color:"#"},
{name:"Other Social Sciences",color:"#"}]},
{text:'Natural Sciences', topics:[{name:"Space sciences",color:"#00695c"},
{name:"Earth sciences",color:"#8bc34a"},
{name:"Biology",color:"#64dd17"},
{name:"Chemistry",color:"#00bfa5"},
{name:"Physics",color:"#009688"},
{name:"Material Sciences",color:"#0a7e07"},
{name:"Other Natural Sciences",color:"#259b24"}]},
{text:'Engineering', topics:[{name:"Mechanical",color:"#"},
{name:"Chemical",color:"#"},
{name:"Civil",color:"#"},
{name:"Electrical",color:"#"},
{name:"Other Engineering",color:"#"}]},
{text:'Formal Sciences', topics:[{name:"Applied Math",color:"#738ffe"},
{name:"Computer Science",color:"#7986cb"},
{name:"Logic",color:"#5c6bc0"},
{name:"Pure Math",color:"#4e6cef"},
{name:"Statistics",color:"#3949ab"},
{name:"Systems Science",color:"#283593"},
{name:"Other Formal Sciences",color:"#5677fc"}]},
{text:'Other', topics:[{name:"Other",color:"#"}]}
];}]);
Change this:
<select
class="form-control"
id="categorize"
ng-model="category"
ng-options="cat.text in cat of categories"
></select>
to:
<select
class="form-control"
id="categorize"
ng-model="category"
ng-options="cat.text for cat in categories"
></select>
and see if that doesn't work for you.