私は、アクションを実行する前にポップアップ警告モーダルを提示したいと考えています(この場合はを削除します)。モーダルでokay
をクリックすると、cancel
をクリックすると処理が続行されます。角モーダルリターン約束
これを行うには、最初の呼び出しである$rootScope.openDirections('warning').then(...
にチェーンに沿ってモーダルの約束を返そうとしています。そこで何をすべきかを決めることができます。
私はエラーを取得していますが:。
$ rootScope.openDirections(...)、関数ではありませんat Scope.$scope.deleteObj
約束が返されていないことを私に告げる:
$scope.deleteObj = function (id, type) {
$rootScope.openDirections('warning').then(function (res) {
// Do Stuff
}, function (err) {
console.log('ERROR', err);
});
これは$ rootScope関数を呼び出します。(私はここでは、オブジェクトタイプが約束です...ので、元の発信者に今戻ることができないことを参照してください?)
方向性を開くためにModal
工場を呼び出し
$rootScope.openDirections = function (type) {
// A Promise: Object {result: Promise, opened: Promise, rendered: Promise}
return Modal.showDirections(type);
};
は、モーダル:
message.html
モーダルテンプレートレンダリング
return {
...
showDirections: function(type) {
return $modal.open({
backdrop: 'static',
templateUrl: 'modal.html',
controller: 'directionsCtrl',
resolve: {
// Display custom modal template
obj: function() {
if (type === 'markdown') {
return {
template: '/modals/directions.html'
};
} else {
return {
template: '/modals/message.html'
};
}
},
testID : function() {
return 'WHAT DO I RETURN HERE?';
}
}
});
}
:モーダルためdirectionsCtrl
を使用しています
<div class="admin-directions">
<div class="directions">
ARE YOU SURE YOU WANT TO DELETE THIS?
</div>
<p class="dismiss-admin-help" ng-click="okay()">Okay</p>
<p class="dismiss-admin-help" ng-click="cancel()">Cancel</p>
</div>
:
angular
.module('DDE')
.controller('directionsCtrl', ['$rootScope', '$scope', '$modalInstance', 'Modal', 'obj', 'Auth', 'VARS', '$route', '$location', 'testID',
function ($rootScope, $scope, $modalInstance, Modal, obj, Auth, VARS, $route, $location, testID) {
$scope.template = obj.template;
$scope.testID = '';
/**
* Dismiss modal
*/
$scope.ok = function() {
$scope.testID = 'okay';
return $modalInstance.result($scope.testID);
};
$scope.cancel = function() {
$scope.testID = 'cancel';
return $modalInstance.result($scope.testID);
};
}]);
大丈夫、私の '$ modal'インスタンスは、同じ範囲内ではありませんコントローラではなく、それ自身の工場内にある。したがって、元の呼び出し元に戻すために、工場内で正確に何を解決するのですか? – Growler
それはどういう意味ですか?あなたが私の提案したことをしたときにあなたのエラーは消えましたか? – mcgraphix
'$ scope.ok'と' $ scope.cancel'ボタンはモーダルでは機能しません – Growler