使用ng-options在选择下拉列表中显示对象数据

时间:2016-06-27 06:19:56

标签: javascript html angularjs

我正在尝试将angularJS与Symfony2一起使用。 对于初学者,我试图使用ng-options在简单的下拉列表中显示对象的文本属性作为选项。 这是HTML

var app = angular.module("programDropdown", []);
app.controller("myCtrl", function($scope) {
        $scope.programofinterests = [
            {id: '0', text: 'Masters - Information Systems Management'},
            {id: '1', text: 'Masters - Software Engineering'},
            {id: '2', text: 'Masters - Computer Security'},
            {id: '3', text: 'Bachelors of Computer Science'},
            {id: '4', text: 'Exchange Program'},
            {id: '5', text: 'Study Abroad'},
            {id: '6', text: 'Scientific Summer School'},
            {id: '7', text: 'French Summer School'},
            {id: '8', text: 'ME - Global IT Management'},
            {id: '9', text: 'ME -  Software Development and Multimedia'},
            {id: '10', text: 'ME - Systems, Networks and Security'}
        ];
});

这是脚本

 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_bypassing_buffer      = 'X'
    it_fieldcat             = lt_fieldcat
    i_callback_program      = sy-repid
    i_save                  = 'A'
    i_callback_user_command = 'USER_COMMAND'
    is_variant              = ls_variant
  TABLES
    t_outtab                = lt_qmel_mat
  EXCEPTIONS
    program_error           = 1
    OTHERS                  = 9.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

然而结果是空的下拉列表。看一下屏幕截图的左上角 enter image description here

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

首先尝试修复&#34; JQuery&#34;和&#34;要求&#34;的问题。这可能也会修复你的Angular问题,但不能保证,因为Angular通常不需要JQuery。它有一种轻量级的JQuery嵌入式。

您可以在控制器中放置一个断点,看看调试器是否到达那里。