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) –