내가 가지고있는 다음과 같은 지침 :
지침 1 개
app.directive('tableDiv', function() {
return {
templateUrl: 'js/directives/table-div/table-div.html',
replace: true,
scope: {
table: '=',
},
controller: function ($scope, $element, $attrs) {
},
link: function postLink(scope, element, attrs) {
}
}
});
지침 1 템플릿 :
<div data-table-div-row value="row" sizes="table.tbody.sizes" ng-repeat="row in table.tbody.values">
</div>
지침 2 :
app.directive('tableDivRow', function ($rootScope) {
return {
templateUrl: 'js/directives/table-div/table-div-row.html',
replace: true,
scope: {value: '=', sizes: '='},
controller: function ($scope, $element, $attrs) {
$scope.showInfo = function() {
$scope.visible = true;
};
$scope.hideInfo = function() {
$scope.visible = false;
};
$scope.hasTemplate = function() {
return ($scope.value.template ? true : false);
}
},
link: function postLink(scope, element, attrs) {
scope.$watch(function() {
return scope.visible;
}, function (value) {
if (value === true) {
$(element).find('div.table-row').addClass('open');
$(element).find('div.table-row.edit').removeClass('hidden');
} else {
$(element).find('div.table-row').removeClass('open');
$(element).find('div.table-row.edit').addClass('hidden');
}
}, true);
}
}
});
Directive 2 templa 테 : 나는 컨트롤러 $ 범위 모델을 기반으로 동적 템플릿을 포함하고있어 두 번째 지침 템플릿 내부
<div>
<div class="row-fluid">
<div class="table-row clearfix">
<div class="{{sizes.first}} first">{{value.display.first}}</div>
<div ng-repeat="cell in value.display.cells" class="{{sizes.cells[$index]}}">{{cell}}</div>
<div class="{{sizes.last}} last regular">
<div ng-switch on="value.display.last">
<div ng-switch-when="%editbutton%">
<div class="show-info closed" ng-click="showInfo()"></div>
</div>
<div ng-switch-default>
{{value.display.last}}
</div>
</div>
</div>
</div>
</div>
<div ng-if="hasTemplate()">
<ng-include src="value.template"></ng-include>
</div>
. 해당 템플릿과 지시문 템플릿에서 컨트롤러 $ scope에서 함수를 호출하려고합니다. 그것을 성취 할 수있는 방법이 있습니까?
이제 문제가 생겼습니다. 두 번째 지시어의 컨트롤러에서 나는'$ scope.expandCallback && $ scope.expandCallback ("text");와 같은 무작위 값을 가진 함수를 호출하려고합니다. 그러나 인수는 컨트롤러 범위 메소드에 전달되지 않습니다. 'console.log (arguments)'는 빈 배열을 출력합니다. – lucassp
'{message : "text"}' – Direvius