0
작동에 대한 정보가 필요한 지시문을 작성 중입니다. 그러나 그 정보는 약속에서 나옵니다. 지시문 자체가 더 많은 시간을 요구하기 때문에 그 정보없이 지시문이로드됩니다.지시어 링크 실행 전 각도 데이터를 얻으십시오.
angular.module('app').directive('tagInput', tagInput);
var tagInput = function ($timeout, profileService) {
var profileList = profileService.getProfileList();
profileList.then(function (profiles) {
var profileObject = {};
var profilesFiltered = [];
for(var index in profiles){
if(profiles[index].hasOwnProperty('id')){
var notStandard = profiles[index].id.match(/\d+/g);
if (notStandard != null) {
profileObject.icon = '<i class="fa fa-bookmark" aria-hidden="true"></i>';
}
else{
profileObject.icon = '<i class="fa fa-user" aria-hidden="true"></i>';
}
profileObject.name = profiles[index].name;
profileObject.identifier = profiles[index].id;
profileObject.ticked = false;
profilesFiltered.push(profileObject);
}
}
return profilesFiltered;
});
return {
restrict: 'EA',
require: 'ngModel',
scope: {
tags: '=ngModel',
searchParams: '=searchParams'
},
replace: false,
link: function (scope, element, attrs) {
scope.modelFilter = {
showSearchPanel: false,
inputProfiles: profilesFiltered,
...
이렇게하면 항상 템플릿의 데이터가 비어있게됩니다. 지시어 링크 실행 전에 어떻게 데이터를 준비 할 수 있습니까? 아마도 inputAccounts: accountsFiltered,
과 비슷한 약속이 필요합니다.