0

私は次のコードを持っています:

angular.module('myApp').controller('modalClickItemController', function ($scope, $dialog) {

$scope.openDialog = function(opts){
    console.debug('bar');
    var d = $dialog.dialog(opts);
    d.open().then(function(result){
        console.debug('foobarbazz');
    });
}

});

これは、次のようなディレクティブで使用されます。

 angular.module('myApp')
.directive('modalClickItem', function () {
    return {
        restrict: 'A',
        controller: 'modalClickItemController',
        link: function postLink(scope, el, attr){
            scope.objectId = attr.objectId;
            scope.objectType = attr.objectType
            scope.opts = {
                backdrop: true,
                keyboard: true,
                backdropClick: true,
                template: "<div class='modal-header'>Hi!!!</div><div class='modal-body'>Buy!!!</div>",
  //                    templateUrl:  'views/'+scope.objectType+'_modal.html',
                controller: 'modalCtrl'
            }

            el.on('click', function(){
                scope.openDialog(scope.opts);

            });
        }
    };
});

このコードは bar を出力しますが、foobarbazz は出力しません。角度付きブートストラップにデバッグを貼り付けると、open メソッドに入り、promise を返しますが、ダイアログは開きません。

http://plnkr.co/edit/tNokVEbRds78tBaVZtLH?p=preview

なんで?

4

1 に答える 1

0

私はjquery.bootstrap.jsを使用します。これは非常に小さくてシンプルで、easyui と似ています。

$("#loginwrap").dialog({
      title:    "Login"
    , buttons: [
        {
            text: "Close"
          , classed: "btn-primary"
          , click: function() {
              $(this).dialog("close");
            }
        },
        {
            text: "Login"
          , classed: "btn-success"
          , click: function() {
              //your login handler

              $(this).dialog("close");
            }
        }
      ]
});
于 2013-10-18T23:59:03.373 に答える