0
html 요소에서 부모 컨트롤러의 함수 (myAppController)로 전달되는 주소 개체를 전달하려고합니다. 부모 컨트롤러 내부의 컨트롤러 (예 : DialogController)에 연결합니다. 편집 버튼을 클릭하면 주소 개체의 요소가 md 대화 상자에 표시 될 때 md 대화 상자가 생성됩니다. MD 대화 상자가 작동하지만 주소의 항목을 표시 할 수 없습니다. 이 내 컨트롤러html 요소에서 부모 컨트롤러의 함수로 전달되는 개체를 부모 컨트롤러 내에있는 컨트롤러에 전달하는 방법
(function() {
'use strict';
angular
.module('myApp')
.controller('myAppController', myAppController);
myAppController.$inject = ['$scope', '$state','AddressesService'];
function myAppController ($scope, $state, AddressesService) {
var vm = this;
vm.addresses = AddressesService.query();
// this is a long controller so i cut short it to important part
$scope.showAdvanced = function(address, ev) {
$mdDialog.show({
controller: DialogController(address),
templateUrl: '/modules/carts/client/views/edit.tmpl.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose:true,
fullscreen: $scope.customFullscreen // Only for -xs, -sm breakpoints.
});
function DialogController($scope, $mdDialog, address) {
console.log("address"+" "+address); // says undefined
$scope.hide = function() {
$mdDialog.hide();
};
$scope.cancel = function() {
$mdDialog.cancel();
};
$scope.answer = function(answer) {
$mdDialog.hide(answer);
};
}
};
}
}());`
이며,이 대화 컨트롤러에 데이터를 전달하는 올바른 방법이 시도 '지역 주민'
매개 변수를 사용하는 것입니다 내 HTML
<div ng-repeat="address in vm.addresses">
<h5 class="list-group-item-heading uppercase bold" ng-bind="address.name"</h5>
<button ng-click="showAdvanced(address, $event)">Edit</button>
</div>`