I am trying to develop a dynamic dialog box. The text is coming on a $http.get response. but somehow it is not working. A little help will be really appreciated. I am using node.js and 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);
};
}
}]);
Template ejs code
<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>
I am trying to display the 'app_modes' list on the md-dialog.