ng-repeat被注释掉了

时间:2015-11-08 15:48:10

标签: javascript angularjs

我有以下测试应用程序,其中我使用AngularJS尝试在选择中显示选项。

JS

var ClarityApp = angular.module("Clarity", ["ngResource"]);
  ClarityApp.controller("HeaderController", function ($scope, clientData) {
    $scope.ClientList = clientData.getClients();
    $scope.ClientList.then(
    function (e) {
      console.log(e);
    },
    function (f) {
      console.log(f)
    }
  );
});

ClarityApp.factory("clientData", function ($resource, $q) {
  var client = $resource("/api/client", { isArray: true });
  return {
    getClients: function () {
      var deferred = $q.defer();
      client
      .query(
        {}, //params
        function (event) { deferred.resolve(event); },
        function (response) { deferred.reject(response); }
       );
      var promise = deferred.promise;
      return promise;
    }
  }
});

HTML:

    <li>
      <label>Client</label>
      <select ng-repeat="Client in ClientList">
        <option>{{ Client.ClientName }}</option>
      </select>
    </li>

JSON从服务器返回:

[
  {
      "ClientID": 3,
      "ClientName": "Client1"
  },
  {
      "ClientID": 4,
      "ClientName": "Client2"
  }
]

当我运行应用程序时,ng-repeat部分被注释掉了。没有返回任何错误。

0 个答案:

没有答案