0
いずれかの回答でダイアログを確認した後にthis.status
を変更することはできますか?
class ComponentCtrl {
constructor($scope, $reactive, $mdDialog) {
'ngInject';
$reactive(this).attach($scope);
this.$mdDialog = $mdDialog;
this.status = "Click button below to set status";
}
showDialog(event) {
this.$mdDialog.show(confirm).then(function() {
// Yes
console.log('I like dogs');
this.status = 'I like dogs'; //doesn't work
}, function() {
// No
console.log('I love cats');
this.status = 'I love cats'; //doesn't work
});
}
}
を回避する方法は、オプションでカスタムダイアログ(https://material.angularjs.org/latest/api/service/$mdDialog)を定義することです:あなたは親コントローラのすべての変数/関数にアクセスすることができますが、それはもっとたくさんのコードが含ま上記のケースで
locals: { ParentCtrl: this },
bindToController: true
クイックダイアログにngMaterialの短縮形を使用するのではなく、
は何をしたい、このですか? - http://codepen.io/camden-kid/pen/JKBqYN?editors=1010#0 –
@camden_kid ES6クラス構文とMeteorを使用する場合、上記は機能しません。解決策は次のとおりです。ありがとう! – srokatonie