[英]Angularjs directive bind template manually
我正在創建一個龐大的表,當點擊表的每個單元格時,模式打開,並且從后端獲取有關該單元格的一些細節並顯示。 這個模態將不得不重復使用,因此我將其創建為角度指令。
.directive('ltInstanceStatus', function() {
return {
restrict: 'A',
scope: {
instanceId: '=ltInstanceId'
},
link: function(scope, element, attributes) {
var getInstanceStatus = function() {
// get Instance Status and pop modal
};
element.bind('click', getInstanceStatus);
},
templateUrl: '/assets/templates/instance_status.html'
};
})
這工作正常但我想當單元格數量增加時,頁面加載也會增加。 有沒有這樣的方式,我有一個單獨的模式html和重復使用它同時更改數據同時將其保存在不同的文件夾中。
這段代碼檢查
.directive("chartDir",function(){
return {
restrict: 'E',
transclude: true,
template: '<h2>Hello world!</h2> <div role="tabpanel" ng-transclude></div>',
scope: { },
link: function(scope, elem, attr) {
elem.on('click', function() {
scope.$apply(function() {
});
});
}
}
});
單擊常用函數中的每個單元格傳遞每個唯一值並調用然后應用返回寫入公共服務並檢索數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.