2014-07-01 42 views
0

我想刪除的一個標籤href屬性(例如純文字工作),我在我的指令文件中使用此代碼:AngularJS刪除的href

.directive('rhHasLinkFor', function() { 
    return{ 
     priority: 10000, 
     restrict: 'A', 
     compile: function (el, attr) { 
       el.href.remove(); 

     } 

    } 
}); 

,但它不工作,有什麼問題呢?

回答

2

嘗試

.directive('rhHasLinkFor', function() { 
    return{ 
     priority: 10000, 
     restrict: 'A', 
     compile: function (el, attr) { 
       el.removeAttr('href'); 
     } 

    } 
}); 
+0

我想這一點,但它沒有工作了。 –

+0

你能提供一個演示你的問題的小提琴嗎? [這是](http://jsfiddle.net/joshdmiller/HB7LU/)一個空的角度小提琴。 – gorpacrate

+0

我提供了它[這裏](http://jsfiddle.net/HB7LU/4680/) –