角度数据未显示

时间:2016-10-05 20:30:18

标签: angularjs angular-http

我正在尝试使用站点中的$ http服务GET方法来填充字段。下面是我调用API和插入数据的方法。另请注意,由于与Laravel发生冲突,我将{{}}替换为<%%>。当我在没有API调用的情况下测试$scopes并且一切正常时,我很确定这与此无关。

var app = angular.module('metaDashboard', []);

/**Changes {{variable}} to <%variable%> for Laravel implementation
*/
app.config(function ($interpolateProvider) {
    $interpolateProvider.startSymbol('<%');
    $interpolateProvider.endSymbol('%>');
});

/**This is for the meta-dashboard home page and sets the correct number of the below variables.
*/
app.controller('TotalNumberController', ['$scope', '$http', function($scope, $http) {
  $http.get('/api/userCount')
      .then(function successCallback(response) {
        $scope.clientCount = response.data["client"];
        $scope.campaignCount = response.data["campaign"];
        $scope.accountCount = response.data["accounts"];
        $scope.userCount = response.data["user"];
    }, function errorCallback(response) {
        $scope.clientCount = "N/A";
        $scope.campaignCount = "N/A";
        $scope.accountCount = "N/A";
        $scope.userCount = "N/A";
    });
   }
]);

0 个答案:

没有答案