LoginSignup
0
0

More than 5 years have passed since last update.

UiKitのmodalでhidden showのイベントをAngularJSのDirectiveから追加する

Last updated at Posted at 2016-06-02

UIKitのモーダルの閉じるときにイベントを差し込みたい。

UIKit:http://getuikit.com/docs/modal.html

$('.modalSelector').on({

    'show.uk.modal': function(){
        console.log("Modal is visible.");
    },

    'hide.uk.modal': function(){
        console.log("Element is not visible.");
    }
});

こうじゃなくてJqueryを使わないでやりたい

AngularJSのDirective

angular.module('docsSimpleDirective', [])
.controller('Controller', ['$scope', function($scope) {
  $scope.test = function(){
    console.log("test");
  }
}])
.directive('myDomDirective', function () {
    return {
        scope: {
            test: "&"
        },
        link: function ($scope, element, attrs) {
            element.bind('hide.uk.modal', function () {
                $scope.test();
            });
        }
    };
});

Plunker
https://plnkr.co/edit/gipUQxDCxMaE2OO0ofRd?p=info

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0