0
每次添加元素時,都會再次觸發該指令。我只是想將elem納入icr主模態佈局元素。防止角JS指令在移動元素時觸發兩次
.directive('icrMainModal', function() {
return {
restrict: 'E',
templateUrl: 'views/icr-main-modal.html',
scope: {
state: '=icrVState'
},
transclude: true,
compile: function(elem, attrs) {
angular.element('icr-main-modal-placement').append(elem); // because of this, the directive is fired again. I just want to move elem into 'icr-main-modal-placement'
return function(scope, elem) {
scope.$on('$destroy', function() {
return elem.remove();
});
};
}
};
});
你可以顯示你的HTML如何使用它? – PSL 2014-09-05 20:09:06