我想將一個以html/jquery編寫的舊應用程序移植到angularjs。該方案是有一個名單和雪佛龍的點擊它顯示它下面的圖標集(下圖)Angular JS指令
要走的路就是指令,我試圖修改一個適合的場景。我不清楚的是,我將如何限制一次只有一組圖標。 ()。icon-set)。hide()它會隱藏所有的圖標,並在需要的時候點擊,例如點擊雪佛龍顯示圖標。
在角度的情況下,我有多個問題。我創建這個列表
<ul class="list" ng-repeat="file in files| filter: { folder:'false' }" >
<li class="list-main" >
<ext-img file-name="{{file['file-name']}}"></ext-img>
<div class="list-info">
<div class="list-header">{{file['file-name']}}</div>
<div class="list-info-bottom dimfont"><small>{{ file['modified-timestamp'] | date:'medium' }}</small></div>
</div>
<action-button class="chevron" id="{{file['file-path']}}/{{file['file-name']}}"></action-button>
</li>
</ul>
的指令,不工作的element.bind()(下面的代碼) 和我怎麼只顯示其在列表中的元素之一。
myapp.directive('action-button',function(){
return {
restrict: 'E',
template: {
},
link: function(scope,element,attrs){
// This populates the options mene, Bind onclick event
element.bind("click",function(){
// Append the options to it.
var str = '';
str += "<div class=\"options-box\">" ;
str += "<ul class=\"options-inner\">" ;
str += "<li class=\"options-item\">" ;
str += "<a href=\"#\" ng-click = \"\">" ;
str += "<img class=\"options-img\" src=\"images/share_file.png\">" ;
str += "<div>Share</div>" ;
str += "</a>" ;
str += "</li>" ;
str += "</ul></div>";
element.replaceWith(str);
}
)
}
}
})
編輯:我可以修復不工作的問題,我感到困惑的是如何使它只顯示一個圖標集。 編輯:固定錯字
我終於搞定了。你不知道我多麼感恩,我被困在它上面超過3天。非常感謝。我使用了$ rootScope。$ broadcast(「hideAll」)和$ scope。$ on(「hideAll」,function(){})的第一種方法。這是我的最終代碼。 http://play.golang.org/p/efMi8Mr05r再次感謝。 :) – pers3us