AngularJS指令单击只能调用一次

时间:2013-08-28 14:28:21

标签: javascript angularjs

我正在制定一个显示模态的指令。它第一次通过,但第二次或任何时候,点击不再有效。代码如下所示:

<li><a href="http://example.com/JohnDoe" profile-modal="JohnDoe">JohnDoe</li>

EngagementApp.directive('profileModal', ['$compile', 'Request', '$modal', '$q',

函数($ compile,Request,$ modal,$ q){

return {
    restrict : 'A',
    link : function(scope, element, attrs) {

        element.bind('click', function(e) {
            e.preventDefault();
            scope.modal = { 
                username : attrs.profileModal,
                url : main_site_url
            };

            var modalPromise = $modal({template: '/templates/profile.html', persist: true, show: false, backdrop: 'static', scope: scope});

            $q.when(modalPromise).then(function(modalEl) {
                modalEl.modal('show');
            });

        });

    }
};

}]);

如何让点击工作多次,而不仅仅是第一次?我用于模态的框架是angularstrap。 http://mgcrea.github.io/angular-strap/

0 个答案:

没有答案
相关问题