Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript n选项不是';t显示“我的选择”元素中的任何选项_Javascript_Html_Angularjs_Ng Options_Angularjs Ng Options - Fatal编程技术网

Javascript n选项不是';t显示“我的选择”元素中的任何选项

Javascript n选项不是';t显示“我的选择”元素中的任何选项,javascript,html,angularjs,ng-options,angularjs-ng-options,Javascript,Html,Angularjs,Ng Options,Angularjs Ng Options,我的一个select元素中有一个Ngoption连接到我在控制器中创建的数组,它只是没有显示任何值。我一定在做傻事 我确信Angular正在工作,控制器也一定在工作,因为我在同一个div中使用了一个与ngModel相关的表达式(使用同一个控制器),它工作得很好 这是我的html的相关片段: 分类 这是我的js文件: var tagQuestionnaireApp = angular.module('tagQuestionnaireApp', []); tagQuestionnaireA

我的一个select元素中有一个Ngoption连接到我在控制器中创建的数组,它只是没有显示任何值。我一定在做傻事

我确信Angular正在工作,控制器也一定在工作,因为我在同一个div中使用了一个与ngModel相关的表达式(使用同一个控制器),它工作得很好

这是我的html的相关片段:


分类

这是我的js文件:

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:"#"}]}
    ];}]);
更改此项:

<select 
  class="form-control" 
  id="categorize" 
  ng-model="category" 
  ng-options="cat.text in cat of categories"
></select>

致:



看看这是否对你不起作用。

应该是分类中的猫的
cat.text
Wow,我甚至在上次使用这个时检查过它。我知道这会很愚蠢。谢谢我刚刚看到朱棣文发表了一篇评论,大意是这样的。如果他把它贴出来作为答案,接受他的答案,而不是我的。不用担心,你可以把这个标记为答案。我太忙/懒得创建一个。:)
<select 
  class="form-control" 
  id="categorize" 
  ng-model="category" 
  ng-options="cat.text for cat in categories"
></select>