HB.Core.Directives.directive('hbMultiselect', [
function() {
return {
restrict: 'E',
templateUrl: '/hb-core/library/directives/hb-multiselect/hb-multiselect-ptl.html',
scope: {},
controllerAs: '$ctrl',
bindToController: {
optionsData: '<',
optionsSelected: '=',
allSubtypesSelected: '='
},
controller: function() {
var $ctrl = this;
// $ctrl.$onInit = function() {
// console.log(this); // Tried this... didn't work either
// };
function init() {
$ctrl.isExpanded = false;
$ctrl.optionsDisplay = [];
$ctrl.tags = [];
console.log("------")
console.log($ctrl);
console.log("------")
>>>>>>>>>>>>>>>>>>>>**BREAK POINT HERE**
}
init();
}
};
}
]);
있을 때 나는없이 중단 점을 코드 를 실행하면 내 angular1.6 컨트롤러가 I이 이유는 브레이크 포인트를
바인딩을 얻을 제대로 결합하지 않는 optionsData
, optionsSelected
및 allSubtypesSelected` 예상대로 작동합니다. 내가 (위의 코드에 지정된) 코드 내가 얻을에 중단 점을 넣을 때 어떤 이유로 의
난 아무것도 변경하지 않은 다음! 내 코드 $ ctrl.optionsData 디버깅 할 때 정의되지 않은 이유는 모르겠지만 내 코드가 작동하지 않습니다.
어 ... 나는 실제로 맨 위에있는 내 의견에서 볼 수 있듯이 실제로 시도했지만 작동하지 않았습니다. 나는 그것을 다시 시험해 보았다 :/설명에 감사드립니다! –
$ onInit은 구성 요소에서만 작동합니까? –
구성 요소 (각도 2+) 대신 컨트롤러를 의미합니까? '$ onInit'은 컨트롤러에 대해 올바르게 작동합니다 (여기에 컨트롤러는 제공된 코드의 지시문 정의 안에 정의되어 있습니다). – BrendanBenting