0

单击选择(选项)列表时,我有一个奇怪的行为。

服务.js:

services.factory('AppAPIService', function($resource){
    return {
        serviceReports: $resource('rest/services/report', {}, {query: {method: 'GET', params: {}, isArray: false }})
    }});

控制器.js

app.controller('AppCtrl1', ['$scope', 'AppAPIService', function($scope, AppAPIService) {

$scope.reportsQuery = AppAPIService.serviceReports.query();

$scope.setSelectedItem = function($rep) {

    //$('#selectedJobTemplates').empty();
    var sourceList = document.getElementById($rep); 

    $scope.availableReports = $scope.reportsQuery[sourceList.selectedIndex].reports;
    console.error($scope.reports);
}}]);

部分 HTML 代码:

<div>
    <label for="workspace">Reporting</label>
    <div>
        <select name="reports" id="reports" ng-change="setSelectedItem('reports')">
                <option value="Full">Full</option>
                <option value="Quarter">Quarter</option>
        </select>
    </div>
</div>

   <div>
    <div>A</div>
        <div>
            <select name="availableReports" id="availableReports" class="height150" size="10" ng-model="availableReports" ng-options="item for item in availableJobTemplates">
            </select>
       </div>
    </div>

和给定的 JSON:

{"reportsQuery":[{"workspace":"HR & Management","reports":["Sales","Management","Marketing","Human-Resources"]},{"workspace":"Engineering","reports":["IT-Conultant","IT-Administration","Developer","Tester","Requirements-Engineer"]}]}

问题:在选择“报告”列表“A”的 ng-change 时正确填写。但是在列表 A 中选择一个元素后,元素(在列表 A 中)消失并且所选元素(例如“开发人员”)在每一行中逐个字符地显示?

我没有分配点击监听器?

在此处输入图像描述 在此处输入图像描述

4

0 回答 0