1

我在加载页面时遇到了一个小问题。有时, myng-options有空白值。我不明白为什么。我可以毫无问题地加载页面 10 次,但我可以加载带有空白值的页面。

但是,返回的 JSON 不为空。总是相同的结果:

服务 :

myApp.factory('GenericService', function ($http, $q) {
    var data;

    function getDataIfNeeded(the_action) {

        the_action = the_action || 'default';

        if (data !== undefined) {
            return $q.when(data);
        }

        return $http({
            url: "php/functions.php",
            method: "GET",
            params: { 
                action: the_action
            }
        }).then(function(response) {
            data = response.data;
            return data;
        });
    }

    return {
        getData: getDataIfNeeded
    };
});

控制器 :

GenericService.getData("get_leaders").then(function (data) {
  $scope.leaders = data;
});

...

GenericService.getData("get_experts_ux").then(function (data) {
  $scope.experts_ux = data;
});

JSON:

   [
      {"lead_technique_id":1,"lead_technique_name":"Delphine ____"},
      {"lead_technique_id":2,"lead_technique_name":"Thierry ____"}
   ]

HTML:

     <select ng-model="newProject.lead_technique_id" ng-options="leader.lead_technique_id as leader.lead_technique_name for leader in leaders" required></select>

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

4

0 回答 0