The goal: to use components and not use $scope to set data. There isn't an error to share, the issue is that the data element isn't set when the dialog loads the component. The screen shot shows the current state of the dialog, there should be an object bound in tab #2 (Info). I can verify the the object (document) is available after the dialog loads using the onComplete event. I've tried to bind the data available to the dialog call to the component in the following ways below:
1 using locals:
locals: {
document: document
},
bindToController: true,
onComplete: function(){
console.log('document: %O', document);
}
2 using bindings:
bindings: {
document: '='
}
3 using resolve:
resolve: {
document: function() {
return document;
}
}
The component:
I believe the error is here, the bindings, the "old way" used $scope vars so the bindings wired effortlessly.
(function(){
'use strict';
angular.module('adminClientApp')
.component('documentEdit', {
templateUrl: 'js/app/components/document/documentEdit/document-edit.html',
controller: function DocumentEditController($mdToast, $mdMedia) {
var var documentEdit = this;
documentEdit.document;
},
bindings: {
document: '<'
}
});
})();
the dialog call
the DialogController just has the $mdDialog events in it. I realize that the locals and bindToController are targeting the controller specified in the dialog (DialogController). I'm stumped here - how to set/pass/wire the document to the component controller?
this.showEdit = function ($event, document) {
var parentEl = angular.element(document.body);
$mdDialog.show({
parent: parentEl,
targetEvent: $event,
template: '<div><document-edit document="documentEdit.document"></document-edit></div>',
resolve: {
document: function(){ return document;}
},
controller: DialogController,
onComplete: function(){
console.log('document: %O', document);
}
});
}