0
我試圖簡單地將一些JSON數據從GET調用扔到頁面上。角JS控制器功能沒有進入
這是我的HTML(請注意,這是裝入的index.html具有正確的角符號):
<h1>Downloads</h1>
<div class="container" ng-controller="DownloadCtrl as download">
<p>{{download.routes}}</p>
</div>
這是下載控制器:
(function(){
'use strict';
angular.module('dashboardApp').controller('DownloadCtrl', DownloadCtrl);
DownloadCtrl.$inject= ['DownloadService'];
function DownloadCtrl(DownloadService){
var self = this;
self.routes = function(){
DownloadService.getRoutes()
.then(function(responseData) {
self.routes = responseData;
});
};
};
})();
這是下載服務:
(function(){
'use strict';
angular.module('dashboardApp')
.factory('DownloadService', DownloadService);
DownloadService.$inject = ['$http', '$sessionStorage'];
var baseURL = 'http://localhost:8080/Dashboard/rest/download/';
function DownloadService ($http, $sessionStorage){
var service = {};
service.getRoutes = getRoutes;
return service;
function getRoutes(){
return $http.get(baseURL+"route",$sessionStorage.sessionData.sessionID);
}
}
})();
我有調試d的應用程序,它確實打到self.routes但是它只是跳過它,並沒有數據顯示。
我也沒有收到控制檯中的任何錯誤。它只是跳過功能。
這是我的第一個AngularJS應用程序。
是的,我剛剛注意到,我分配了兩次,這是非常愚蠢的。 – Softey
你應該接受並投票給我! – Hitmands
1投票指出我的錯誤,但即使將DownloadService分配給getRoutes調用也不能解決問題。我認爲這個問題還有更多。 – Softey