समस्या यह है कि बाल निर्देश माता-पिता से बंधे हैं हालांकि वाक्यविन्यास {{name}}
ng-repeat
द्वारा अनदेखा हो जाता है। इसे प्राप्त करने का सही तरीका क्या होगा?कोणीय निर्देश/बाल निर्देश एनजी-दोहराने के अंदर स्थानांतरित करें
एचटीएमएल (मुख्य/बच्चे के निर्देश)
<compact-select
no-item-selected-text="Add a Customer"
no-item-selected-icon="fa-user"
search-placeholder="Type a customer name"
cs-model="customer"
cs-items="contacts"
>
<display-item-template>
<span>{{name}}</span>
or
<span>{{item.name}}</span>
</display-item-template>
</compact-select>
निर्देशक
angular.module('core').directive('compactSelect', [function($timeout) {
return {
templateUrl : 'modules/core/views/components/compact-select-tpl.html',
bindToController: true,
transclude: true,
scope: {
noItemSelectedText: '@',
noItemSelectedIcon: '@',
csModel: '=',
csItems: '=csItems'
},
controllerAs : 'ctrl',
controller : function($scope) {
}
};
}]).directive('displayItemTemplate', function($timeout) {
return {
require: '^compactSelect',
restrict: 'E'
}
});
निर्देशक टेम्पलेट (मॉड्यूल/कोर/विचारों/घटकों/कॉम्पैक्ट-चयन-tpl.html)
<div class="compact-select-repeater-box" style="" >
<div ng-transclude ng-repeat="item in ctrl.csItems | filter:searchParam" class="compact-select-repeater" ng-class="ctrl.getHighlightedClass(item)" ng-click="ctrl.itemSelected(item)">
<span>{{item.name}}</span>
<span>{{item.id}}</span>
</div>
<div style="position:absolute;bottom:0">
<a href="#">+ Click here to add customer {{ctrl.message}}</a>
</div>
</div>
मैं देख सकता हूँ कि
<span>{{item.name}}</span>
<span>{{item.id}}</span>
साथ
<span>{{name}}</span>
or
<span>{{item.name}}</span>
प्रश्न
<span></span>
or
<span>{{item.name}}</span>
और नहीं के साथ बदल जाता है: बाल निर्देश से एचटीएमएल बाइंडिंग वाक्यविन्यास का सम्मान करने के लिए मुझे ng-repeat
कैसे मिल सकता है? या यह हासिल करने का एक और तरीका है?
वाह ... यह शानदार काम करता है। निर्देशक क्षेत्र जीवन चक्र को समझाने के लिए धन्यवाद। – Tim