ユーザー情報を含むオブジェクトを ng-include テンプレートに渡す必要があります。テンプレートは、現在取り組んでいるビューよりも多く使用されることが予想されるため、オブジェクトがどのコントローラーからのものかがわからないため、通常の「ctrlName.user.name」を使用できないため、問題が発生します来る。コントローラーは次のとおりです。
angular.module('QW').controller('schoolCtrl', function ($state, schoolHandler, userHandler) {
var vm = this;
vm.activeTemplate;
vm.activeTemplateUser;
vm.templates = {
'edit-employee' : 'app/templates/edit-profile-modal.html'
}
vm.editEmployee = function(){
// This part should naturally come from database normally
vm.activeTemplateUser = {
firstname : "John",
lastname : "Doe",
email : "John@Doe.com",
phonenumber : "XXXX XXXX XXXX",
profile_pic : "assets/img/profile.png"
}
// Fetches template URL
vm.activeTemplate = vm.templates["edit-employee"];
// Opens modal in which the data is to be inserted
var inst = $('[data-remodal-id=edit-user-modal]').remodal();
inst.open();
}
});
ここに私のインクルードと初期化に従ってください:
<div class="remodal" data-remodal-id="edit-user-modal" data-remodal-options="hashTracking: false" id="edit-user-modal">
<div ng-init="user = school.activeTemplateUser" ng-include="school.activeTemplate"></div>
</div>
そして最後に私のテンプレート:
<div id="edit-profile-information">
<h5>Förnamn{{user.name}}</h5>
</div>
つまり、次のように設定して、activeTemplateUser にテンプレート内のユーザーを表すようにします。
ng-init="user=school.activeTemplateUser"