我有11個儀表板,我想顯示inOrder。 所以我的HTML代碼如下所示:如何在JQuery Selector中調用遞歸函數
<button type="button" class="btn btn-default" ng-model="settings.isBigger" ng-disabled="false" btn-checkbox btn-checkbox-true="true" btn-checkbox-false="false" tooltip="{{settings.maximized ? 'Minimize in Order': 'Maximize in Order'}}" tooltip-placement="bottom">
<i class="icon-resize-full-alt"></i>
</button>
最大化類:頁擴展。
$( 「儀表盤」)中的.class jQuerySelectors(具有類=儀表盤的所有元素)
所以每個陳述應該採取3秒所以我用的setTimeout。
相同的過程將是連續的,所以我的功能必須是遞歸的。
//$(".dashboard").each(function (index) . This code my foreach loop in dashboards.
和我的NG-型號代碼如下所示:
link: function (scope, elem, attrs, controller) {
elem.on('$destroy', function() {
$log.log("I am here");
});
scope.$watch('settings.isBigger', function() {
$(".dashboard").each(function (index) {
function inOrder() {
$(this).addClass("maximize" + index)
setTimeout(function() {
$(this).removeClass("maximize" + index)
$(this).addClass("maximize" + index + 1)
}, 3000)
};
return inOrder;
})
});
}
我的代碼不能正常工作。 你能幫我嗎?
但我不會ng-repeat,因爲我不使用儀表板名稱。所以我必須在我的控制器中使用ng-repeat代替foreach循環。 – eagle
你可以展示一個更完整的例子,你如何在HTML中呈現儀表板? –