2
반복적 인 코드에 대한 지시문을 쓰고 싶습니다. 예를 들어이 샘플에서는 attachUsageService에서 데이터를로드 한 다음 html을 생성합니다. 첫 번째 단계 서비스가 데이터를 성공적으로로드했지만이 데이터가 생성 된 html 요소에 바인딩되지 않았습니다. 버튼의 텍스트를 "테스트 [수]"그것을 클릭 한 후, 예를 들면없는 이유를 지시링크 함수에서로드 된 날짜가 지시어에서 만들어진 HTML에 바인드 된 이유는 무엇입니까?
app.directive('mySharedScope', ["abp.services.app.attachmentUsage", function (attachmentUsageService) {
return {
restrict: 'AE',
template: ' <button ng-click="open()">Test {{attachments.length}}</button><div>',
scope: { },
link: function ($scope, $element, $attrs) {
var attachments = [];
$scope.open = function() {
var _objectType = 0;
var _objectId = $attrs.objectId;
if ($attrs.objectType == 'person')
_objectType = 1;
if ($attrs.objectType == 'company')
_objectType = 2;
abp.ui.setBusy(null,
attachmentUsageService.getObjectAttachments({ objectId: _objectId, objectType: _objectType, itemCount: 10 }).success(function (data) {
attachments= data.attachments;
alert(attachments.length);
}));
};
}
};
}]);
에 대한 코드 아래 가정 ?
정말 고마워요. 그것은 작동합니다. – Omital
@Omital : 환영합니다. – Thalaivar
또 다른 질문 : 링크 함수에서 html을 만들고 바인딩 할 수 있습니까? – Omital