Tôi đang cố gắng loại bỏ href hoặc các thuộc tính ng-href khỏi một góc (v1.2.28) Chỉ thịXóa href với chỉ thị góc
hoạt động tốt khi url không có nội suy chuỗi trong đó.
Bạn có thể giúp tôi tìm ra điều này không?
Tôi chỉ cần thực hiện một jsfiddle đây http://jsfiddle.net/gfvewv5u/1/
angular.module('ui.directives', []);
angular.module('ui', ['ui.directives']);
angular.module('ui.directives', []).directive('uiTool',
function() {
return {
restrict: 'EAC',
require: '?ngModel',
link: function($scope, element, attrs, controller) {
var controllerOptions, options;
attrs.$set('href', null);
element.removeAttr('href');
element.text('iamfoo for what');
}
};
});
angular.module('myApp', ['ui.directives'])
.controller('testCtrl', function($scope){
$scope.val = 1;
});
Và HTML
<div ng-app="myApp">
<div ng-controller="testCtrl">
<a ui-tool href="/test/ts/{{val}}" >Link need to be removed</a>
<a ui-tool href="/test/ts" >Link remove</a>
</div>
</div>
Dựa trên ví dụ của tôi mắt xích đầu tiên vẫn có những href trong khi liên kết 2 doens't
Bạn đã xác định các mô-đun angular.module góc ('ui.directives', []) ;. Vì vậy, loại bỏ [] từ angular.module ('ui.directives', []) chỉ thị ('uiTool', – intekhab