0
我正在嘗試開發一個動態對話框。文本來自$ http.get響應。但不知何故,它不工作。一點幫助將非常感激。我使用node.js和angular。
angular.module('rugCoPro')
.controller('DashboardController', [
'$scope',
'Session',
'$location',
'ObjectUtils',
'$http',
'$state',
'$stateParams',
'$mdDialog',
function(
$scope,
session,
$location,
ObjectUtils,
$http,
$state,
$stateParams,
$mdDialog
){
if(!session.isAuthenticated()){
session.logout();
}
$http.get("api/models/department").success(function(response, status, headers){
$scope.app_modes = response;
});
$scope.load = function(ev) {
$mdDialog.show({
controller: DialogController,
template:
'<md-dialog aria-label="List dialog">' +
' <md-dialog-content>'+
' <md-list>'+
' <md-list-item ng-repeat="item in items">'+
' <p>{{item.name}}</p>' +
' </md-list-item>'+
' </md-list>'+
' </md-dialog-content>' +
'</md-dialog>',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
locals: {
items: $scope.app_modes
},
});
};
function DialogController($scope, $mdDialog) {
$scope.items = $scope.app_modes;
$scope.hide = function() {
$mdDialog.hide();
};
$scope.cancel = function() {
$mdDialog.cancel();
};
$scope.answer = function(answer) {
$mdDialog.hide(answer);
};
}
}]);
模板EJS代碼
<md-content ng-controller="DashboardController as ctrl" class="md-padding" ng-init='load()'>
<div layout="row" layout-align="start center">
<h6 class="md-headline">{{"Turco Persian Rug Co."| uppercase}}</h6>
</div>
</md-content>
我想顯示在MD-對話框中的「app_modes名單。
*「它不工作」*告訴我們旁邊什麼也不要求我們問你很多問題。花幾分鐘時間查看[問],然後用適當的技術問題說明和故障排除詳細信息更新問題。 – charlietfl
可能重複[如何從異步調用返回響應?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) –